I have many xyz files that I want to run through awk. I just want to create a new file with an _s appended, for each one. Having a little trouble getting the basename syntax correct. Here is what I have.for i in *.xyz; do awk -F  '{printf $1 $2 $3}' > $(basename $i)_s.xyz ; done
can't get an awk for loop to work, while using basename
awk;basename
The proper syntax for writing the output of processed files to new files with _s added to the filename part before the extension would be:for i in *.xyz; do awk -F  '{printf $1 $2 $3}' $i > ${i%\.*}_s.xyz ; donethe ${i%\.*} part takes trims the $i string from the last occurence of . to the end effectively removing the extension.In your example you could use ${i%\.xyz}, but that would be less universal.