Using sed, how do you print the first 'N' characters of a line?

前端 未结 6 1439
北荒
北荒 2020-12-22 20:28

Using sed what is an one liner to print the first n characters? I am doing the following:

grep -G \'defn -test.*\' OctaneFullTest.clj          


        
6条回答
  •  臣服心动
    2020-12-22 20:56

    Don't use sed, use cut:

    grep .... | cut -c 1-N
    

    If you MUST use sed:

    grep ... | sed -e 's/^\(.\{12\}\).*/\1/'
    

提交回复
热议问题