If you just want to ignore the first line, there's no good reason to use tail
at all!
{
read -r first_line
while IFS= read -r line; do
printf '%s\n' "$line"
done
} <filename.txt
Using read
to consume the first line leaves the original file pointer intact, so following code can read directly from the file, instead of reading from a FIFO attached to the output of the tail
program; it's thus much lower-overhead.
If you did want to use tail
, for the specific case raised, you don't need to use a process substitution (<(...)
), but can simply pipe into your while
loop. Note that this has a serious side effect, insofar as any variables you set in the loop will no longer be available after it exits; this is documented (in a cross-shell manner) in BashFAQ #24.
tail -n +2 filename.txt | while IFS= read -r line
do
printf '%s\n' "$line"
done