LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 02-25-2005, 05:45 AM   #1
robsamms
LQ Newbie
 
Registered: Feb 2005
Posts: 2

Rep: Reputation: 0
Linux Console Scripting


Hi
I hava a coursework assignment and I have a question which I am completely stuck on. The question reads:

Write a pipeline that updates the content of a file (a file of your choice) by replacing all matches of the word 'and' with the symbol '&' and by replacing the end of each line with "your name". If the command completes successfully it should print 'YES' otherwise it should print"NO".

Please help as I am completely stuck on this.

Thanks Rob.
 
Old 02-25-2005, 05:52 AM   #2
Ephracis
Senior Member
 
Registered: Sep 2004
Location: Sweden
Distribution: Ubuntu, Debian
Posts: 1,109

Rep: Reputation: 50
Ok, you should consider using gawk to get singel words and so on from the content. use egrep to search for 'and' in a file and then you can play a little with stuff like cat and so on. Check man for those commands and you will figure it out.

We can't do the homework for you.
 
Old 02-25-2005, 06:13 AM   #3
robsamms
LQ Newbie
 
Registered: Feb 2005
Posts: 2

Original Poster
Rep: Reputation: 0
I managed to write a pipeline that changed the and's to &'s but it only placed my name at the end of each paragraph not each line the script is:

sed -i 's/and/\&/g;s/$/'`whoami`'/g' ./filename && echo YES || echo NO
 
Old 02-25-2005, 07:23 AM   #4
Sepero
Member
 
Registered: Jul 2004
Location: Tampa, Florida, USA
Distribution: Ubuntu
Posts: 734
Blog Entries: 1

Rep: Reputation: 33
Your sed command seems to work perfectly on my pc. Perhaps there are no end of lines until the end of each of your paragraphs.
 
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
linux scripting help anirudh Programming 6 03-04-2005 10:33 PM
console scripting help cs-cam Linux - General 2 01-12-2005 02:04 PM
How to Run Win32 Console App in linux Console Lokie Linux - Software 2 08-12-2004 10:00 PM
Linux Scripting netkepala Linux - Networking 5 02-21-2003 09:14 PM
Scripting in Linux Phantom Linux - Newbie 1 11-07-2001 03:31 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 12:57 PM.

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