Seth McClaine
Seth McClaine

Reputation: 10040

How to create a file with text, date, and file content in command line

I'm looking to create an alais in IOS Terminal that will create a file with a comment at the top of the file and append another file to the end

Output I would like

\#2Thu Dec  3 14:39:41 MST 2015
--fileContents--

Attempt

echo # > x.txt; date >> x.txt; cat file.txt >>> x.txt;

But the results put the # and the date on separate lines... How would I do it with keeping them on the same line

Upvotes: 0

Views: 135

Answers (1)

Seth McClaine
Seth McClaine

Reputation: 10040

I've found that adding ` around date inside of an echo executes the statement.

Resolution

echo # `date` > x.txt; cat file.txt >> x.txt;

Upvotes: 1

Related Questions