Reputation: 169
I am trying to reverse the order of multiple text files (for plotting purposes) which are essentially rows of numbers. I tried to do it with tac
and combined it with find
and -exec
as
find ./dir1/dir2/ -name foo.txt -type f -exec tac {} \;
but this only gives the output on the screen and does not modify the files intended.
Am I missing something here?
Upvotes: 2
Views: 465
Reputation: 16060
You're almost there - tac
writes to stdout
so you can simply redirect the output somewhere handy:
find .... \; > newfoo.txt
If you want each file reversed and written to the same location, something like this will do:
find . -type f -exec sh -c 'tac "$1" > "$1"-new' -- {} \;
Cheers,
Upvotes: 2