Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

7.30 Pipeline tr Redirection exercise

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >

Share

Shulou(Shulou.com)06/01 Report--

Exercise:

1. Convert the contents of the / etc/issue file to uppercase and save to the / tmp/issue.out file

Cat / etc/issue | tr'amurz 'Amurz' > / tmp/issue.out

2. Convert the information of the current system login user to uppercase and save it to / tmp/who.out file.

Who | tr 'AmurZ'aMurz' > / tmp/who.out

3. A linux user sends an email to root, requesting the title of the email is help, the body of the email is as follows, hello,I am user name, the system version is here please help me to check it thanks!

Echo-e'Hello, I am `whoami`, The system version is here, please help me to check it, thanks!\ nlsb_release | mail-s help root

4. Display the list of files under / root/ as a line, and separate the file names with spaces.

Method 1: ls / root | tr'\ n''

Method 2: echo $(ls-a) | tee > file1

5. The content of the file1 file is: 1 2 3 4 5 6 7 8 9 10 calculate the sum of all the numbers

Method 1:echo "1 2 3 4 5 6 7 8 9 10" | tr'+'| bc

Method 2:echo $[`echo "1 2 3 4 5 6 7 8 9 10" | tr'+'`]

6. Delete the ^ M character from the Winodows text file

Method 1:cat a.txt | tr-d'\ 015' > f2.txt

Method 2:cat a.txt | tr-d'\ r'> f2.txt

7. Process the string "xt,. | 1 jr#-smn2 c*/fe 3 uz 4", leaving only numbers and spaces in it.

Echo 'xt,. | 1 jr#-smn2 c*/fe 3 uz 4' | tr-cd [: digit:]'\ n'

8. Display the PATH variable on a separate line for each directory

Echo $PATH | tr':'\ n'

9. Delete the blank line of the specified file

Cat F1 | tr-s'\ n'

10. Display each word (letter) in the file on a separate line with no blank lines

Cat / etc/init.d/functions | tr-cs'[: alpha:]'\ n'

Replace all except letters with empty ones

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Network Security

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report