john hidalgo
john hidalgo

Reputation: 1

Piping with multiple commands

Assume you have a file called “heading” as follows

echo "Permissions^V<TAB>^V<TAB>Size^V<TAB>^V<TAB>File Name" > heading

echo "-------------------------------------------------------" >> heading

Write a (single) set of commands that will create a report as follows: make a list of the names, permissions and size of all the files in your current directory, matching (roughly) the format of the heading you just created, put the list of files directly following the heading, and save it all into a file called “file.list”. All this is to be done without destroying the heading file.

I need to be able to do this all in a pipleline without altering the file. I can't seem to do this without destroying the file. Can somebody please make a pipe for me?

Upvotes: 0

Views: 130

Answers (1)

kev
kev

Reputation: 161674

You can use command group:

{ cat heading; ls -l | sed 's/:/^V<tab>^V<tab>/g'; } > file.list

Upvotes: 1

Related Questions