I was trying to write a shell script wherein I can extract the headers and also the filename from a list of files in a given directory.
ABC_TESTFILE1.csv contains headers like
ABC_TESTFILE2.csv contains headers like
I want output text file as:
I was trying my luck as:
#!/bin/bash # Go to where the files are located filedir=/home/vikrant_singh_rana/AAA_USP/Combined-Files/* for filepath in $filedir do #echo "Processing $filename" # do something on $f var_head=$(head -n 1 basename "$filepath" ) echo "$var_head" done; > test.txt