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

前端 未结 6 1429
北荒
北荒 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 21:04

    To print the N first characters you can remove the N+1 characters up to the end of line:

    $ sed 's/.//5g' <<< "defn-test"
    defn
    

提交回复
热议问题