PDA

View Full Version : [SOLVED] Trying to understand the >> function



Drenriza
November 8th, 2010, 11:00 AM
im using the following command

diff test2 test1 | grep -E '^>|^<'What i want to do is check to different files, to see what new lines that has been added.
when doing this i get this output (random text i added, to test the command)

cristian@cristian-Znote:~/Skrivebord$ diff test2 test1 | grep -E '^>|^<'
> las vegas(ny)
> jail(ny)
> jaw(ny)What i would like to do with this output is copying it to a file with the > symbol.
But when i try to do

diff test2 test1 | grep -E '^>|^<' | > test3i just get an empty file. I dont get the output of the previously command pasted into the file. Hope you can see what i am trying to do. Dont rly know how to explane it :(

Anyone who can tell me what i'm doing wrong?
Thanks on advance.

r-senior
November 8th, 2010, 11:06 AM
You don't need the pipe ('|') before the redirection ('>').



diff test2 test1 | grep -E '^>|^<' > test3


or, if you want to append each time ...



diff test2 test1 | grep -E '^>|^<' >> test3

Drenriza
November 8th, 2010, 11:23 AM
Thanks, so far so good :)

But when i do
diff test2 test1 | grep -E '^>|^<' > test3How do i then place the test3 in a pre-defined path?
for example i want to place it in
/home/cristian/something/something

r-senior
November 8th, 2010, 11:32 AM
$ diff test2 test1 | grep -E '^>|^<' > /home/cristian/something/something/test3


or use the ~ expansion for your home directory:



$ diff test2 test1 | grep -E '^>|^<' > ~/something/something/test3

Drenriza
November 8th, 2010, 11:37 AM
Thanks alot :)