"for" loop with awk
Hi, I am new to linux and awk, and am trying to run a script that will execute an awk command that deletes the first column of a file for every file in a directory.
I think it should look like this: for i in *; do awk '{$1=""}1' $i > $i_done.txt; done When I run this it finished, but I don't get any new output files, only one file called ".txt" which appears to have all the results in it. But when take the command out of the for loop and just run it on one file, it works exactly as it should. I am using Cygwin on a windows box. Any help appreciated. Thanks, Mike |
You're using a variable which is not assigned:
Code:
> $i_done.txt Code:
> ${i}_done.txt |
Hi,
And welcome to LQ! And a sed alternative that saves you the loop... Code:
sed -r -iori 's/^[^ \t]+[^ \t](.*)/\1/' * Cheers, Tink |
All times are GMT -5. The time now is 07:16 PM. |