linux中如何删除文本开头的多个空格和tab键
1、测试数据
[root@centos7 test]# ls test.txt [root@centos7 test]# cat test.txt ## 测试数据 y j k j k h d j r [root@centos7 test]# sed -n l test.txt y\tj k$ \t\tj k\th$ \t\td\t\t j r$
2、
[root@centos7 test]# ls test.txt [root@centos7 test]# cat test.txt y j k j k h d j r [root@centos7 test]# sed -n l test.txt y\tj k$ \t\tj k\th$ \t\td\t\t j r$ [root@centos7 test]# sed 's/^[\t ]\+//' test.txt ## 删除行首空格和制表符 y j k j k h d j r
3、
[root@centos7 test]# ls test.txt [root@centos7 test]# cat test.txt y j k j k h d j r [root@centos7 test]# sed -n l test.txt y\tj k$ \t\tj k\th$ \t\td\t\t j r$ [root@centos7 test]# sed 's/^[\t ]*//' test.txt y j k j k h d j r
4、
[root@centos7 test]# ls test.txt [root@centos7 test]# cat test.txt y j k j k h d j r [root@centos7 test]# sed -n l test.txt y\tj k$ \t\tj k\th$ \t\td\t\t j r$ [root@centos7 test]# sed 's/^\s\+//' test.txt y j k j k h d j r
5、
[root@centos7 test]# ls test.txt [root@centos7 test]# cat test.txt y j k j k h d j r [root@centos7 test]# sed -n l test.txt y\tj k$ \t\tj k\th$ \t\td\t\t j r$ [root@centos7 test]# sed 's/^\s*//' test.txt y j k j k h d j r