![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| 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 !! |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| redirection | DNAx86 | Shell Programming and Scripting | 9 | 04-18-2008 11:24 AM |
| csh stderr redirection | jolok | Shell Programming and Scripting | 0 | 04-15-2005 07:03 AM |
| I/O redirection within a coprocess | Mugin | Shell Programming and Scripting | 4 | 10-21-2003 05:17 AM |
| Help with redirection | Shallon1 | High Level Programming | 2 | 12-12-2001 04:35 AM |
| redirection to tty** with cat | zorro | UNIX for Dummies Questions & Answers | 1 | 11-02-2001 08:23 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
sed redirection
I am messing around with sed and I observed the following.
I have as test file a file named errors which contains: Quote:
Code:
sed 's/^> //' errors Code:
sed 's/^> //' errors > errors When I redirect the output to another file it seems to work. For example the file asdf contains the results: Code:
sed 's/^> //' errors > asdf Code:
echo `sed 's/^> //' errors` > errors Is it because the output is guaranteed that will be redirected after it is completely calculated? What's the difference? I am looking forward to your replies. Last edited by myle; 03-11-2008 at 04:56 PM. |
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
Hi.
This is a succinct description of how the shell can destroy the file in your situation: Quote:
It's common to run across this apparently surprising outcome in early use of *nix -- best wishes ... cheers, drl |
|
#3
|
|||
|
|||
|
So, I guess this worked because the
Code:
sed 's/^> //' errors So, it's a matter of priorities, right? |
|
#4
|
||||
|
||||
|
HI.
If we consider priorities as the predefined sequence of events that the shell goes through to process a command, yes. I usually refer people to the O'Reilly book on the bash shell or the Korn shell. In the former, around page 178 is a flow-chart and explanation of the steps. Step 7 is command substitution ( the back-quotes or the more modern $(...) ), and step 12 is the setup of I/O redirection, etc. ... cheers, drl |
||||
| Google The UNIX and Linux Forums |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|