POSIX Shell Programming Challenge - Programming On Unix

Users browsing this thread: 2 Guest(s)
seninha
Long time nixers
The idea I had is to print the content of test/ delimited with \0 by find(1) and loop over it, using readlink(1) to get the full path of the file.

Code:
for i in `find test/ -mindepth 1 -maxdepth 1 -name '*' -print0`
do
    readlink -f "$i"
done

But it would require setting $IFS to \0. And setting $IFS to nul means that no splitting occurs rather than splitting on the nul character.

EDIT: My answer is not qualified for the challenge. My find(1) man page says that the -print0 primary is a non-POSIX extension. But it could be easily replaced with -print, I think.


Messages In This Thread
POSIX Shell Programming Challenge - by mort - 12-04-2021, 10:36 AM
RE: POSIX Shell Programming Challenge - by movq - 12-04-2021, 10:49 AM
RE: POSIX Shell Programming Challenge - by s0kx - 12-04-2021, 11:47 AM
RE: POSIX Shell Programming Challenge - by s0kx - 12-04-2021, 01:31 PM
RE: POSIX Shell Programming Challenge - by jkl - 12-04-2021, 01:34 PM
RE: POSIX Shell Programming Challenge - by sth - 12-04-2021, 01:36 PM
RE: POSIX Shell Programming Challenge - by mort - 12-04-2021, 01:52 PM
RE: POSIX Shell Programming Challenge - by mort - 12-04-2021, 02:35 PM
RE: POSIX Shell Programming Challenge - by seninha - 12-04-2021, 02:49 PM
RE: POSIX Shell Programming Challenge - by movq - 13-04-2021, 03:34 PM
RE: POSIX Shell Programming Challenge - by s0kx - 16-04-2021, 02:50 AM
RE: POSIX Shell Programming Challenge - by s0kx - 01-05-2021, 04:56 AM