3

i'm trying use one line of code to solve a problem

echo $(find . -maxdepth 1 -type f -newer $1  | sed 's,\.\/,,g')

this will print out all the file in current folder that are newer than the input file. But it prints out in one single line:

file1 file2 file3 file4....

how can i display each file name in a single line like:

file1
file2
file3
...

This seems to be a very simple but i've been searching and have no solution. Thank you in advance.

2 Answers 2

6

Get rid of the echo and the $(...).

find . -maxdepth 1 -type f -newer "$1" | sed 's,\.\/,,g'

If you have GNU find you can replace the sed with a -printf action:

find . -maxdepth 1 -type f -newer "$1" -printf '%P\n'
Sign up to request clarification or add additional context in comments.

Comments

0

pipe it to tr:

... | tr " " "\n"

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.