Home > Back-end >  List files in a specific format in bash
List files in a specific format in bash

Time:08-14

I have a bunch of files that look like this:

file1.txt
file1.log
file2.txt
file2.log
file3.txt
file4.log
.
.
.
filen.txt
filen.log

I want to store them in a variable like this:

./file1.,./file2.,./filen.,./stable.file.

How can I do this? Please note that stable.file. is a fixed string.

Thanks so much

CodePudding user response:

Something along:

printf "./%s\n" file*.txt stable.file. | sed 's/txt$//' | paste -sd,
  •  Tags:  
  • bash
  • Related