tasks a-s
This commit is contained in:
parent
47bf37c096
commit
b83f433714
12433 changed files with 156208 additions and 123 deletions
|
|
@ -0,0 +1,7 @@
|
|||
# This while loop repeats for each line of the file.
|
||||
# This loop is inside a pipeline; many shells will
|
||||
# run this loop inside a subshell.
|
||||
cat input.txt |
|
||||
while IFS= read -r line ; do
|
||||
printf '%s\n' "$line"
|
||||
done
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
# This loop runs in the current shell, and can read both
|
||||
# the old standard input (fd 1) and input.txt (fd 3).
|
||||
exec 3<input.txt
|
||||
while IFS= read -r line <&3 ; do
|
||||
printf '%s\n' "$line"
|
||||
done
|
||||
exec 3>&-
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
# The old Bourne Shell interprets 'IFS= read' as 'IFS= ; read'.
|
||||
# It requires extra code to restore the original value of IFS.
|
||||
exec 3<input.txt
|
||||
oldifs=$IFS
|
||||
while IFS= ; read -r line <&3 ; do
|
||||
IFS=$oldifs
|
||||
printf '%s\n' "$line"
|
||||
done
|
||||
IFS=$oldifs
|
||||
exec 3>&-
|
||||
Loading…
Add table
Add a link
Reference in a new issue