Print numbers along with file names.

Hi All,

I have some thousand files with names like 1.syl, 2.syl, 5.syl etc.

These files contain one sentence each. I want to store all those sentences along with the file ID that is 1, 2, 5 with the sentences they contain.

For example,

1.syl has

this is a test line

2.syl has

this is another line

5.syl has

I am done

I want my output to be like this:

this is a test line 1
this is another line 2
I am done 5

This is what I am trying on my Linux system but it is giving me error:

for num in `seq 1 1674` ; do
test ! -f $num.syl && continue
 "$i";echo;cat "$i"; done
$ for i in *.syl; do line=$(cat $i); echo $line ${i%.*}; done
this is a test line 1
this is another line 2
I am done 5
1 Like
for i in *.syl;do echo $(<$i) ${i%.*};done

We don't need UUoC

1 Like

Just in case...
UUoC = Useless Use of Cat

awk '{split(FILENAME,arr,".");print $0 FS arr[1]}' *.syl

--ahamed

1 Like