Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/logging/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Shell Scipt子串_Shell_Substring - Fatal编程技术网

Shell Scipt子串

Shell Scipt子串,shell,substring,Shell,Substring,请帮助我得到下面的情况脚本 我的文件内容如下所示 AllIdPropert.txt ID | PropertyBit| 我需要将所有Id提取到不同的文件中,其中PropertyBit[5]==1,其中第5位为1,格式如下 5bitenable.txt 2| 3| 4| `此awk单衬套应能完成以下工作: awk -F'|' 'substr($2,5,1)==1 {print $1FS}' file 使用示例输入进行测试: kent$ awk -F'|' 'substr($2,5,1)==

请帮助我得到下面的情况脚本

我的文件内容如下所示

AllIdPropert.txt ID | PropertyBit|

我需要将所有Id提取到不同的文件中,其中PropertyBit[5]==1,其中第5位为1,格式如下

5bitenable.txt

2|
3| 
4|

`

此awk单衬套应能完成以下工作:

awk -F'|' 'substr($2,5,1)==1 {print $1FS}' file
使用示例输入进行测试:

kent$  awk -F'|' 'substr($2,5,1)==1 {print $1FS}' f
2|
3|
4|

谢谢你,肯特,这正是我需要的。@Suman没问题。但如果你能理解它是如何工作的,那就太好了。这是awk的基本用法。所以,将来若你们有类似的需求,你们可以自己处理。
kent$  awk -F'|' 'substr($2,5,1)==1 {print $1FS}' f
2|
3|
4|