Sign up ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

I am using AIX 6.1 ksh shell

I want to use one liner to do something like this

cat A_FILE | skip-first-3-bytes-of-the-file  

I want to skip the first 3 bytes of the first line, is there a way to do this?

share|improve this question

migrated from Oct 24 '12 at 21:26

This question came from our site for professional and enthusiast programmers.

2 Answers 2

up vote 7 down vote accepted

Old school — you could use dd:

dd if=A_FILE bs=1c skip=3

The input file is A_FILE, the block size is 1 character (byte), skip the first 3 'blocks' (bytes). There are other ways too:

sed '1s/^...//' A_FILE

This works if there are 3 or more characters on the first line.

tail -c +4 A_FILE

And you could use Perl, Python and so on too.

share|improve this answer
Thanks for your help. Both the sed and the tail commands work in AIX 6.1. For the dd command, it should be dd if=A_FILE bs=1 skip=3 in AIX 6.1 – Alvin SIU Oct 25 '12 at 13:55
You may want to use standard input as such cat A_FILE | tail -c +4 with gnu. – MUY Belgium Nov 8 '13 at 7:57

Instead of using cat you can use tail as such:

tail -c +4 FILE

This will print out the entire file except for the first 3 bytes. Consult man tail for more information.

share|improve this answer
Don't know about AIX, but on Solaris you must use /usr/xpg4/bin/tail, at least on my machine. Good tip nonetheless! – BellevueBob Oct 24 '12 at 19:34
@BobDuell It's hard to post something that is compatible with every OS. – squiguy Oct 24 '12 at 20:10
Yes, it works in AIX 6.1 – Alvin SIU Oct 25 '12 at 13:54
@AlvinSIU Good to know. Glad I could help. – squiguy Oct 25 '12 at 15:43

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.