You're viewing a comment by Visu and its responses.

Visu Permalink
April 11, 2013, 20:12

How to write a sed command for:
match a word from the output of a command.

fw_printenv | grep bootcmd
When i execute above command i get the following output
bootcmd=run sdboot3

Now I need a something of the sort
fw_printenv | grep bootcmd | sed ......
which gives sdboot3 and no new line at the end.

Comment Responses

Kevin Permalink
March 04, 2014, 23:40

There's probably an easier way than this, but...

Command: sed -n '/bootcmd=run /{s/bootcmd=run \(.*\)/\1/;p;}' sedtemp.txt

File: cat sedtemp.txt
not it
not it2
not it3
bootcmd=run sdboot3
not the line
nte the droid your looking fO
bootcmd=run sdbootanotherone


August 24, 2014, 02:15

Peter has a nice blog. Here are some ways:

$ cmd | grep bootcmd | grep -o sdboot3 # GNU grep

$ cmd | sed -n "s/.*bootcmd.*sdboot3.*/sdboot3/p"

If you want to eliminate the newline, use tr command.

Daniel Goldman -

Reply To This Comment

(why do I need your e-mail?)

(Your twitter handle, if you have one.)

Type the word "linux_273": (just to make sure you're a human)

Please preview the comment before submitting to make sure it's OK.