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

How to use the mapfile command of Linux

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

This article mainly explains "how to use Linux mapfile command", interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's let Xiaobian take you to learn "how to use Linux mapfile command"!

The mapfile command is used to read lines from standard input or file descriptors and assign them to arrays.

syntax mapfile [parameter]

Common parameters: -n count Get up to count lines from standard input, if count is zero then get all-O origin Start assigning values from the array subscript origin, the default subscript is 0-s count Skip reading the first count line Reference Example First create an example file alpha.log, one lowercase letter per line, 26 lines in total:

[root@linux265 ~]# echo {a.. z} |tr " "\n" >alpha.log [root@linux265 ~]# cat alpha. log a b c d e f g h i j k l m n o p q r s t u v w x y z Read the alpha.log file and store each line in the array myarr (or in the default MAPFILE array if not specified):

[root@linux265 ~]# mapfile myarr Get up to 6 lines of data from standard input: [root@linux265 ~]# mapfile -n 6 myarr Start assigning values from array subscript 6:[root@linux265 ~]# mapfile -O 6 myarr At this point, I believe that everyone has a deeper understanding of "how to use Linux mapfile command", you may wish to actually operate it! Here is the website, more related content can enter the relevant channels for inquiry, pay attention to us, continue to learn!

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

Development

Wechat

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

12
Report