I am needing a Unix script to get and concat all the filenames in a path/folder with the first line in each file.
Example there is a location /bin/etc/target and there are 3 files in it
file1.csv
header,2
file2.csv
header,3
file3.csv
header,4
My output should be
file1.csv,header,2
file2.csv,header,3
file3.csv,header,4
I need a command that gives me this value from the root because I am using another tool to get this output from this location.
I have a sample command awk '{print FILENAME "," $0; nextfile}' *
which works if I am in the directory. It just does not work from the root. I want this command to do something like below
cd /bin/etc/target
awk '{print FILENAME "," $0; nextfile}' *