Quantcast
Channel: Cat all files in a folder including filename by using a for loop? - Unix & Linux Stack Exchange
Browsing latest articles
Browse All 4 View Live

Answer by Black for Cat all files in a folder including filename by using a...

I found a possible solution: for f in *; do echo -e $f"\n\t$(cat $f)"; done

View Article



Answer by Stéphane Chazelas for Cat all files in a folder including filename...

for f in *; do printf '%s\n' "$f" paste /dev/null - < "$f" done Would print the file name followed by its content with each line preceded by a TAB character for each file in the directory. Same with...

View Article

Cat all files in a folder including filename by using a for loop?

With this for loop which I execute directly in the shell, I am able to cat the contents of all files in a folder, with the value beside of it: $ for f in *; do echo -e "\t"$f"\n"; cat $f; done Example...

View Article

Answer by oopsingh for Cat all files in a folder including filename by using...

for f in *; do echo -e "$(cat $f)\t"$f; done

View Article
Browsing latest articles
Browse All 4 View Live




Latest Images