Answer the question
In order to leave comments, you need to log in
How to merge files, while displaying the names of these files in the end?
There are files of the format (year) - (month) - (day) (hour) - (minute) - (second).txt
They contain time codes for videos and descriptions for them
Is there a beautiful bash expression to glue them into one ? Similar format:
(год)-(месяц)-(день) (час)-(минута)-(секунда).mkv
строчка из первого файла
другая строчка из первого файла
третья строчка
(...итд)
----------------
(год)-(месяц)-(день) (час)-(минута)-(секунда).mkv
строчка из второго файла
другая строчка из второго файла
(...итд)
for i in *.txt; do echo "$i" | sed "s/txt$/mkv/; /mkv$/s/^/### /";echo;cat "$i" | awk -F" - " '!/mkv$/ && length($0) > 3 {print "**" $1 "**" " - " $2}';echo;echo "----------------";echo; done > RESULT.md
Answer the question
In order to leave comments, you need to log in
Write a simple script (I have concat.sh)
#!/bin/bash
echo -e "\n--- BEGIN FILE:" $1 "\n" >> $2
cat $1 >> $2
echo -e "\n--- END FILE:" $1 "\n" >> $2
chmod a+x concat.sh
ls -1 *.txt | xargs -n 1 -I {} ./concat.sh {} out
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question