12. Linux input and output redirection and pipe commands

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

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324689239&siteId=291194637
Recommended