How can I `cat` files with a number of fixed lines before/between/after?
0
votes
5
answers
570
views
I am looking for a bash one-liner which can
cat
a number of files with a number of fixed lines.
file1.txt:
file1 line 1
file1 line 2
file2.txt
file2 line 1
file2 line 2
Then I am looking for something like
cat-with-strings foo file1.txt bar file2.txt baz
producing output
foo
file1 line 1
file1 line 2
bar
file2 line 1
file2 line 2
baz
How can I do this in a single line of bash, using standard linux tools (sed, awk, cat, etc) and *without* creating any files to hold foo
, bar
, or baz
?
Asked by spraff
(951 rep)
Jan 25, 2021, 07:00 PM
Last activity: Jul 7, 2025, 08:30 AM
Last activity: Jul 7, 2025, 08:30 AM