The task is to remove n characters from the beginning of the file using the shell . The file is encrypted gpg . The file cannot be overwritten into another file.

    3 answers 3

     dd if=$file of=$file skip=$n iflag=skip_bytes conv=notrunc 

    Further see. Removing a certain number of bytes from the end of the file shell script

    • one
      Yes, and did, although a little earlier than I saw the answer. - Sebefour

    You can use cut for cutting. For example, to delete the first 10 characters:

     cut -c 10- fname.txt > newfile.txt 
    • Cannot overwrite encrypted file. Special requirement - Sebefour
    • one
      @Sebefour contradict yourself :) - Monah Tuk
    • cut will remove from each line, not from the beginning of the file - sercxjo
    • Hmm, yes, you are right. - Jenyay

    Inline you can try this:

     sed -i '1s/^.\{10\}//' fname.txt 

    but valid only for text files.