Ask your own question, for FREE!
Computer Science 7 Online
OpenStudy (tacotime):

UNIX: I want to put the output of a command in a file, but I need it to maintain all the new lines. My code: #!/bin/csh set list = `ls` echo $list On all the websites I go to they say this should work, but for me it still prints the whole thing in one line.

OpenStudy (anonymous):

the following works for me ```sh ls | awk '{print}' ``` Or if you want to save into a file simply redirect ```sh ls | awk '{print}' > file ```

OpenStudy (anonymous):

Unless I misunderstood what you mean

OpenStudy (mathmate):

try ``` set list=`ls -1` ``` Note the last character is the digit 1. Or if it does not work, use the awk solution proposed by @pitamar

OpenStudy (anonymous):

lol, forgot about `ls -1` :)

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!