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

What are the commonly used shell function commands?

2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

This article mainly shows you "what are the commonly used shell function commands", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn "what are the commonly used shell function commands" this article.

1. Read the contents of the file and print it line by line

While read myline

Do

Echo $myline

Done < test.txt

two。 Replace the specified string in the file

1) replace the jack string with tom in the file containing the jack string in the current directory

Sed-I "s/jack/tom/g" `grep "jack"-rl. / `

2) replace the jack string in a file with tom

Sed-I "s/jack/tom/g" test.txt

3. Delete a line in a file that contains a string

Sed-I'/ cat/d' example.txt

Delete lines in the example.txt file that contain cat characters

3. Print out the files under the / opt folder in turn

# / bin/bashfilelist=$ (ls / opt/) for file in $filelist do echo ${file} done is all the contents of the article "what are the commonly used shell function commands?" Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

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

Servers

Wechat

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

12
Report