mirror of
https://github.com/dunwu/linux-tutorial.git
synced 2024-04-15 19:55:24 +08:00
21 lines
359 B
Bash
21 lines
359 B
Bash
#!/usr/bin/env bash
|
|
|
|
# redirecting the for output to a file
|
|
for file in /home/tiandi/*
|
|
do
|
|
if [ -d "$file" ]
|
|
then
|
|
echo "$file is a directory"
|
|
else
|
|
echo "$file is a file"
|
|
fi
|
|
done > output.txt
|
|
|
|
# piping a loop to another command
|
|
|
|
for state in "North Dakota" Connecticut
|
|
do
|
|
echo "$state is next place to go"
|
|
done | sort
|
|
echo "This completes our travels"
|