Thursday, May 16, 2024
1
rated 0 times [  1] [ 0]  / answers: 1 / hits: 1286  / 2 Years ago, fri, october 28, 2022, 1:09:39

I'm running this command to append output text data to a markdown file:


git log -1 --oneline --skip=1 | tee -a page1.md

For the most part functionality is great, but I need to format the output so its readable. Right now, the command above is appending the markdown file like so:


Append1 Append2 Append3

I need it to be formatted as such:


Append1
Append2
Append3

With each time the command being run, a new line is created and populated with the git log information.


thank you for any guidance on the matter.


More From » command-line

 Answers
7

The Hannu's answer looks correct, but if you want to perform it as single line command - one of the possible ways is to use the cat command and process substitution like this:


cat <(git log -1 --oneline --skip=1) <(echo) | tee -a page1.md

It looks like you are using this frequently so you can add the following function at the bottom of your ~/.bashrc file:


function git-log-1 () { cat <(git log -1 --oneline --skip=1) <(echo) | tee -a "$1"

Then do source ~/.bashrc or open a new terminal and use the function as shell command:


git-log-1 page1.md

[#443] Saturday, October 29, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
etzelmortg

Total Points: 430
Total Questions: 105
Total Answers: 106

Location: Suriname
Member since Sun, Jun 13, 2021
3 Years ago
;