I have a directory with several hundred files.
The file format is a space delimited row with an unknown number of columns:
A B C D E F G ...
I need to turn this format
File1 A
File1 B
File2 A
File3 A
File3 B
File3 C
...
I can use grep to display the filename next to each row of results, but i have not found a way to split the row into new lines while retaining the file names.
If you have lots of files, listing them on the command line might not be possible (too many/too large). If you want to run it on all files in the current directory this will work:
ls | xargs awk '{
for( i = 1; i <= NF; i++ )
printf( "%s %s\n", FILENAME, $(i) );
} '