By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,609 Members | 1,142 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,609 IT Pros & Developers. It's quick & easy.

Need help with sed command

P: 1
I have a string: "grep envname text"

I need to remove "envname" from the string, so it can become only "grep text".

Does anyone know how to do it ? thanks in advance.

-Clai
Sep 26 '07 #1
Share this Question
Share on Google+
3 Replies

Expert 100+
P: 511
Expand|Select|Wrap|Line Numbers
  1. echo "grep envname text" | awk '{print $1,$3}'
  2.  
Sep 27 '07 #2

P: 4
Expand|Select|Wrap|Line Numbers
  1. echo "grep envname text" | sed "s/\(grep\)\ \(envname\)\ \(text\)/\1 \3/g"
  2.  
Oct 1 '07 #3

P: 1
I have a string: "grep envname text"

I need to remove "envname" from the string, so it can become only "grep text".

Does anyone know how to do it ? thanks in advance.

-Clai

Hey,

use the following command.......


echo "grep envname text" > test | cat test | sed -e 's/envname//'


rgds
Souvik
Oct 16 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.