偷偷摘套内射激情视频,久久精品99国产国产精,中文字幕无线乱码人妻,中文在线中文a,性爽19p

Linux下將數(shù)據文件的指定域讀取到shell腳本中

運維 系統(tǒng)運維
這個例子說明了怎樣在Linux下shell腳本中從數(shù)據文件讀取特定的域(field)并進行操作。例如,假設文件employees.txt的格式是{employee-name}:{employee-id}:{department-name},以冒號進行劃分,如下所示。

這個例子說明了怎樣在Linux下shell腳本中從數(shù)據文件讀取特定的域(field)并進行操作。例如,假設文件employees.txt的格式是{employee-name}:{employee-id}:{department-name},以冒號進行劃分,如下所示。

$ cat employees.txt 
Emma Thomas:100:Marketing 
Alex Jason:200:Sales 
Madison Randy:300:Product Development 
Sanjay Gupta:400:Support 
Nisha Singh:500:Sales

下面的shell腳本說明了如何從這個employee.txt文件中讀取特定的域(field)。

$ vi read-employees.sh 
#!/bin/bash 
IFS=: 
echo "Employee Names:" 
echo "---------------" 
while read name empid dept 
do 
    echo "$name is part of $dept department" 
done < ~/employees.txt

賦予腳本可執(zhí)行權限后執(zhí)行該腳本

$ chmod u+x read-employees.sh 
$ ./read-employees.sh 
Employee Names: 
--------------- 
Emma Thomas is part of Marketing department 
Alex Jason is part of Sales department 
Madison Randy is part of Product Development department 
Sanjay Gupta is part of Support department 
Nisha Singh is part of Sales department

 

【編輯推薦】

  1. Clojure世界:如何做性能測試
  2. Linux服務器的16個監(jiān)控命令
  3. IE8安全新功能實測,到底給不給力?
責任編輯:趙寧寧
相關推薦

2021-08-20 10:46:25

Shell腳本文件Linux

2021-04-21 08:03:34

腳本Shell讀取

2009-12-03 10:06:33

Ubuntushell腳本

2010-07-13 14:09:07

SQL Server數(shù)

2022-08-30 08:52:04

shell腳本Linux

2017-12-18 10:12:48

LinuxShell命令

2015-07-16 17:13:13

shell分頁讀取MySQL數(shù)據腳本

2011-08-03 11:11:01

本地組腳本

2024-11-27 09:19:25

2010-03-23 16:35:31

shell 腳本編程

2024-02-19 16:15:07

2020-05-28 15:35:21

Linux數(shù)據文件圖像

2016-12-16 09:23:29

LinuxShell腳本

2013-08-07 10:04:37

MySQL數(shù)據恢復

2017-10-11 16:23:59

Linuxinode刪除文件

2010-10-13 14:02:01

MySQL數(shù)據文件

2010-10-29 14:03:39

Oracle移動數(shù)據文

2017-08-25 17:41:17

Paradox數(shù)據文件格式

2010-04-30 16:01:17

2011-08-25 14:26:40

LUA數(shù)據文件
點贊
收藏

51CTO技術棧公眾號