1. Create a new file
touch a.txt
> b.txt
2. Error redirection: 2>
find /etc -name zhaoxing.txt 2> error.txt
3. Enter correct or incorrect information into log.txt
find /etc -name passwd > /tmp/log.txt 2>&1
find /etc -name passwd &> /tmp/log.txt
4. Append >>
5. Convert lowercase to uppercase (input redirection)
tr "az" "AZ" < /etc/passwd
6. Automatically create a file
cat > log.txt << EXIT
> ccc
> ddd
> EXI
7. Check how many files are under /etc?
ls -l /etc/ | grep '^d' | wc -l
8. Check the number of files under /etc and enter the file details into result.txt
ls -l /etc/ | grep '^d' | tee result.txt | wc -l
touch a.txt
> b.txt
2. Error redirection: 2>
find /etc -name zhaoxing.txt 2> error.txt
3. Enter correct or incorrect information into log.txt
find /etc -name passwd > /tmp/log.txt 2>&1
find /etc -name passwd &> /tmp/log.txt
4. Append >>
5. Convert lowercase to uppercase (input redirection)
tr "az" "AZ" < /etc/passwd
6. Automatically create a file
cat > log.txt << EXIT
> ccc
> ddd
> EXI
7. Check how many files are under /etc?
ls -l /etc/ | grep '^d' | wc -l
8. Check the number of files under /etc and enter the file details into result.txt
ls -l /etc/ | grep '^d' | tee result.txt | wc -l