How to search and replace the specific line number string

后端 未结 2 844
一向
一向 2021-01-27 02:52
line_index=\"2d\";

file=\"./Desktop/books.sh\";

sed -i.bak -e $line_index $file

Will delete the entire line that $line_index is pointing to



        
2条回答
  •  失恋的感觉
    2021-01-27 03:13

    To restrict substitution to a line number, add it before the command:

    sed -i "2s/harry/potter/" $file
    

提交回复
热议问题