Need to concatenate a string to each line of ls command output in unix

I am a beginer in Shell script. Below is my requirement in UNIX Korn Shell.

Example:

When we list files using ls command redirect to a file the file names will be stored as below.

$ ls FILE*>FLIST.TXT
$ cat FLIST.TXT
FILE1
FILE2
FILE3

But I need output as below with a prefixed constant string STR,:

$ cat FLIST.TXT
STR,FILE1
STR,FILE2
STR,FILE3

Please let me what should be the ls command to acheive this output.


Source: shell

Leave a Reply