简体   繁体   中英

Replacing GREP and AWK in Windows for Powershell

I have a linux command for a little video cutting library called ffmpeg.

I can use following command in Linux:

ffmpeg -hide_banner -vn -i $1 -af "silencedetect=n=${THRESH}dB:d=${DURATION}" -f null - 2>&1 | grep "silence_end" | awk '{print $5 " " $8}' > silence.txt

Now i need to execute the exact same Kommand on a Windows machine via Powershell or CMD.

I am struggling with replacing the linux specific terms like grep and awk and the expressions they use.

Could someone please give me a proper replacement for this ?

The replacement would be Select-String for both. The grep is a simple pattern match ( -Pattern -SimpleMatch ). The awk part just selects fields 5 and 8. You can use a regular expression pattern for that, just peek at the format produced. PowerShell sets $Matches[] to the various regex matches; [0] is the whole match while the other entries are for grouped sub-matches.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM