LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 12-06-2005, 12:37 PM   #1
stryka
Member
 
Registered: Oct 2005
Distribution: Slackware
Posts: 44

Rep: Reputation: 15
putting word in front of each line in a file


Hi, I have a list of suid programs in a file, and I am trying to figure out how I could go about echo'ing a specific phrase in front of every line in the file. More specifically, "chmod go-r"

Can someone assist me? Thanks
 
Old 12-06-2005, 12:55 PM   #2
gbonvehi
Senior Member
 
Registered: Jun 2004
Location: Argentina (SR, LP)
Distribution: Slackware
Posts: 3,145

Rep: Reputation: 53
Code:
sed -e "s@^@chmod go-r@" -i file
or if you're used to /

Code:
sed -e "s/^/chmod go-r/" -i file

Last edited by gbonvehi; 12-06-2005 at 12:59 PM.
 
Old 12-06-2005, 12:56 PM   #3
MensaWater
LQ Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,831
Blog Entries: 15

Rep: Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669
awk '{print "chmod go-r",$0}' <filename>

The text inside the quotes is literal. $0 represents an entire line. The comma puts a space between the literal text and the line.
 
Old 12-06-2005, 02:32 PM   #4
stryka
Member
 
Registered: Oct 2005
Distribution: Slackware
Posts: 44

Original Poster
Rep: Reputation: 15
Thank you both. It is my plans to learn sed and awk over christmas break. I appreciate your help
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
C++ text file line by line/each line to string/array Dimitris Programming 15 03-11-2008 08:22 AM
add word to each line of the file? ziggie216 Linux - General 4 04-25-2005 04:19 AM
word count in a line pantera Programming 4 08-25-2004 01:14 PM
grabing info and putting it in a file gurkburk Linux - Newbie 7 05-14-2004 10:36 AM
display full line instead of single word in for loop ken734 Linux - Newbie 3 08-15-2003 02:35 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 07:09 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration