开发者

grep - put part of string into variable

开发者 https://www.devze.com 2023-01-07 08:04 出处:网络
I\'m using swfdump to be able to get the ID number of an audio file. Here is what I\'m using: swfdump -D /Users/home/folder/file.swf | grep -i mp3

I'm using swfdump to be able to get the ID number of an audio file. Here is what I'm using:

swfdump -D /Users/home/folder/file.swf | grep -i mp3

That is outputting: [00e] 28999 DEFINESOUND defines id 0006 (MP3 22Khz 16Bit mono)

What I need is the id #..in this case it is 0006. i want that number in a variab开发者_运维问答le. Anyone know how to do this?


the_id=`swfdump -D /Users/home/folder/file.swf | grep -i mp3 | cut -d' ' -f6`


var=$(swfdump -D /Users/home/folder/file.swf | sed '/MP3/s/.*id //;s/ (.*//')

or Bash

$ s=$(swfdump -D /Users/home/folder/file.swf)
$ var=${s/(MP3*}
$ echo $var
0006
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号