how to perform by sed in order to print the line until ";" character
echo "NUMBER = 3247 FULL DUPLEX ; speed=343 434 " | sed .....
need the following output
NUMBER = 3247 FULL DUPLEX
Why don't you use awk for this? i.e.
echo "Number=3247 ; speed=343 434 " | awk {'print $1'}
And if you really need the " in front, use
echo "Number=3247 ; speed=343 434 " | awk {'print "\"" $1'}
EDIT: After feedback (see comments below), here the correct version with sed:
echo "NUMBER = 3247 FULL DUPLEX ; speed=343 434 " | sed 's/\;.*//g'
Use awk
with -F
to specify the field delimiter:
echo "NUMBER = 3247 FULL DUPLEX ; speed=343 434 " | awk -F\; '{print $1;}'
Note that the semicolon is excaped with a backslash so that your shell won't misinterpret the semicolon as the end of the command.