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

Use the mapfile command of linux to read rows from standard input and assign them to an array

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

Share

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

Editor to share with you the use of linux's mapfile command to read rows from standard input and assign values to the array. I hope you will learn a lot after reading this article. Let's discuss it together.

The mapfile command is used to read lines from standard input or file descriptors and assign values to an array

Syntax format: mapfile [parameters]

Common parameters:

Reference example

First create a file alpha.log for the example, one lowercase letter per line, with a total of 26 lines:

[root@linuxcool ~] # echo {a.. z} | tr "\ n" > alpha.log [root@linuxcool ~] # cat alpha.logabcdefghijklmnopqrstuvwxyz

Read the alpha.log file and store each line in the array myarr (if not specified, in the default MAPFILE array):

[root@linuxcool ~] # mapfile myarr

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