0

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?

3
  • 2
    The >> heading appends the output to the heading file; you need to save all to a file called file.list so presumably your command needs to end with >> file.list at some point. You only show how the heading is created. How did you try to tackle the rest? Commented Oct 15, 2013 at 5:00
  • how about something like ls -l | awk '{print $1 " " $5 " " $9}' assuming permissions doesn't include owner/group. Commented Oct 15, 2013 at 5:17
  • i tried ls -l | sed ‘s/:/^V<tab>^V<tab>/g’ | >> heading > file.list Commented Oct 15, 2013 at 5:55

1 Answer 1

1

You can use command group:

{ cat heading; ls -l | sed 's/:/^V<tab>^V<tab>/g'; } > file.list
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.