Skip to content
Advertisement

How to edit a particular line and replace text via sed in linux (cent os)

Width                    : 1 280 pixels
Height                   : 720 pixels

I’m working on a bash script and need to filter video on the bases of resolution. Like If Width is greater than equal to 1280 then HD else Non HD

I’m using mediainfo to make and save info in txt file.

cat /home/The.txt | grep "Width"  |  awk -F ':' '{print $2}' | grep -o "[0-9]*"

output of this is

1
280

this is because of one ” ” between 1 280

For height its alright if i grep height.

Is there anyway I can edit the line of width and make all integers like

1100
1280
1272

from

1 110
1 280
1 272

Advertisement

Answer

I suggest to use:

grep "Width" /home/The.txt | tr -cd '0-9n'
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement