oldfile=test.csv
read -p "Enter File location: "$savelocation1
read -p "Enter File name: " $newfile1
grep "foobar" $oldfile > $savelocation1/$newfile1
awk ' BEGIN {FS=","}
{
printf "%-5s %-10s" \n, $1, $3
} ' < $savelocation1/$newfile1
grep will create a new file called $newfile
that only contains the lines "foobar"
from the $oldfile
but then when i do an awk to print the 1st and 3rd columns into the $newfile1
the problem with this is that it doesn't write the output of awk to the $newfile1
but it just prints the results to the terminal.
Edit - I used a tempory file to store then output then transfer it to the original file. however this only works for grep and not any awk statement for some reason.
$savelocation1/$oldfile> $savelocation1/tempfile.csv && mv $savelocation1/tempfile.csv $savelocation1/$newfile
awk: cmd. line:3: ^ backslash not last character on line