Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/24.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
Linux 识别前导行空格-shell脚本_Linux_Shell_Centos_Ubuntu 14.04_Text Processing - Fatal编程技术网

Linux 识别前导行空格-shell脚本

Linux 识别前导行空格-shell脚本,linux,shell,centos,ubuntu-14.04,text-processing,Linux,Shell,Centos,Ubuntu 14.04,Text Processing,我有一个如下的示例文件。有前导行空格。是否有方法检测它们并使用shell脚本打印包含行空间的准确行号 test space at back test space at front TAB at end TAB at front grep可以找到带有[:blank:]的空格和带有^(regex)的行开头 grep-n将打印行号 试试grep-n'^[:blank:]'文件名这对我有用! 如果grep-n'^'config.js/dev/null>&2;然后 echo“$0:上面标

我有一个如下的示例文件。有前导行空格。是否有方法检测它们并使用shell脚本打印包含行空间的准确行号

test space at back 
 test space at front
TAB at end  
    TAB at front

grep可以找到带有[:blank:]的空格和带有^(regex)的行开头

grep-n
将打印行号

试试
grep-n'^[:blank:]'文件名

这对我有用! 如果grep-n'^'config.js/dev/null>&2;然后 echo“$0:上面标识的前导空格;正在中止”>&2 出口1 fi