Appending a character(#) with string search at the start of the line | Unix Linux Forums | UNIX for Dummies Questions & Answers

  Go Back    


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

Appending a character(#) with string search at the start of the line

UNIX for Dummies Questions & Answers


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 01-08-2013
chandu123 chandu123 is offline
Registered User
 
Join Date: Jan 2012
Last Activity: 3 July 2014, 2:46 PM EDT
Posts: 31
Thanks: 18
Thanked 1 Time in 1 Post
Appending a character(#) with string search at the start of the line

Hello,

I have been browsing through the forum, but unable to find a solution for my requirement.

I need to go through a file and search for
Code:
/home/users

and insert a # symbol at the start
Code:
/home/users

. Example output is
Code:
#/home/users

.

Can you please help me with the awk or sed command for this.Thank you.
Sponsored Links
    #2  
Old 01-08-2013
rdrtx1 rdrtx1 is offline
Registered User
 
Join Date: Sep 2012
Last Activity: 23 September 2014, 12:09 PM EDT
Location: Houston, Texas, USA
Posts: 675
Thanks: 0
Thanked 203 Times in 195 Posts
try:

Code:
sed -i '/\/home\/users/s/^/#/' infile

Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Search several string and convert into a single line for each search string using awk command AIX?. laknar Shell Programming and Scripting 5 12-09-2012 06:33 PM
Search for a string, then append character to end of that line only snoman1 Shell Programming and Scripting 1 11-27-2012 01:25 PM
Appending # to the start of specific line in a properties file mihirvora16 UNIX for Advanced & Expert Users 6 09-16-2011 11:57 AM
Appending string, variable to file at the start and string at end Vaddadi Shell Programming and Scripting 4 03-24-2010 01:31 PM
appending string to text file based on search string malaymaru Shell Programming and Scripting 1 06-09-2006 08:53 AM



All times are GMT -4. The time now is 02:10 AM.