Pipelines


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Pipelines
# 1  
Old 03-05-2007
Pipelines

Now before this thread gets closed, please be aware this is not classwork or homework, I am trying to learn unix by myself, and have come stuck below. So it is a pointless to close this thread, as I am trying to improve my unix by asking advice from people. That is what I assume a forum is for!

I am trying to work out how to complete this question, and after learning a bit more unix. i have written an answer to it. Can anyone check to see if it is correct and what improvements need to be made?

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 the user login name. If the command completes successfully it should print ‘YES', otherwise it should print ‘NO'.

cat text.txt | sed -e s/and/$USER/g -e s/$/”&”/g | cat -> text.txt
&& echo yes || echo no

thanks
vish
# 2  
Old 03-05-2007
Thread closed. The question was asked two years ago on another forum.
Quote:
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.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

4 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

UNIX Pipelines

What if you want to have just one single pipeline that will create a file (let's say x) and we want all the content from another file (we can call it y), one word per line? (7 Replies)
Discussion started by: sarahahah
7 Replies

2. UNIX for Dummies Questions & Answers

Building Pipelines?

How would I combine commands in a pipeline to produce an alphabetized list of who's online at a particular moment? Then: How would I take that pipeline and turn it into a command called "whoison"? (1 Reply)
Discussion started by: greeky
1 Replies

3. Shell Programming and Scripting

Varialble in pipelines

Hi, As per shell docs because commands in pipelines are run as separate processes, variables set in a pipeline have no effect on the parent shell In the sample below I am unable to set variable in Proc1 so that I can see it in the main program Is there any work around ? Thanks Zam... (4 Replies)
Discussion started by: zam
4 Replies

4. UNIX for Dummies Questions & Answers

multiple pipelines

howdy all, i've been trying to find info on piping info between multiple commands from the command line, but i've been unable to find any examples of piping continuous data through a chain of commands. basically, i'm trying to parse data from the top command and send it out over udp to another... (1 Reply)
Discussion started by: ohhmyhead
1 Replies
Login or Register to Ask a Question