Skip to main content
Thank you @Terdon
Source Link
Chris Davies
  • 128k
  • 16
  • 178
  • 323

The starting point for this could be a simple loop:

while IFS= read -r item
do
    [ -f "$item" ] && printf '%s\n' "$item"
done <file.txt

This could be crashed onto a single line at the expense of readability:

while IFS= read -r item; do [ -f "$item" ] && printf '%s\n' "$item"; done <file.txt

Or you could use Perl:

perl -ne 'chomp ($item = $_);lne print'print if -f $item'f' file.txt

The starting point for this could be a simple loop:

while IFS= read -r item
do
    [ -f "$item" ] && printf '%s\n' "$item"
done <file.txt

This could be crashed onto a single line at the expense of readability:

while IFS= read -r item; do [ -f "$item" ] && printf '%s\n' "$item"; done <file.txt

Or you could use Perl:

perl -ne 'chomp ($item = $_); print if -f $item' file.txt

The starting point for this could be a simple loop:

while IFS= read -r item
do
    [ -f "$item" ] && printf '%s\n' "$item"
done <file.txt

This could be crashed onto a single line at the expense of readability:

while IFS= read -r item; do [ -f "$item" ] && printf '%s\n' "$item"; done <file.txt

Or you could use Perl:

perl -lne 'print if -f' file.txt
Source Link
Chris Davies
  • 128k
  • 16
  • 178
  • 323

The starting point for this could be a simple loop:

while IFS= read -r item
do
    [ -f "$item" ] && printf '%s\n' "$item"
done <file.txt

This could be crashed onto a single line at the expense of readability:

while IFS= read -r item; do [ -f "$item" ] && printf '%s\n' "$item"; done <file.txt

Or you could use Perl:

perl -ne 'chomp ($item = $_); print if -f $item' file.txt