Bash script - use current variable value as number to print a line
Hey,
I'm working on a copy script that will copy all files that diff says only appear in the original directory, to the backup directory. Diff gives me this output, so I have to work a little with the string to get the right target path. Quote:
If I write awk 'NR==$i' my variable is empty, with 'NR=='$i'' i get an EOF. Any tips of how I can improve/fix my script? Code: Quote:
|
Edit: Fixed it
I fixed it by adding -v i=$i!
Code:
filename=$(awk -v i=$i 'NR==i' sample.txt | awk '{print $NF}') |
Code:
cp --no-clobber /path/to/original/* /path/to/new/ |
wait, you only want the last field?
Code:
#!/bin/bash the grep is not so useful if you need to factor that in Code:
echo awk |
All times are GMT -5. The time now is 09:14 PM. |