find 4 chars on 2nd line, 44 chars over

I know this should be simple, but I've been manning sed awk grep and find and am stupidly stumped :frowning:

I'm trying to use sed (or awk, find, etc) to find 4 characters on the second line of a file.txt 44-47 characters in. I can find lots of sed things for lines, but not characters.

tail +2 myfile | head -1 | cut -c44-47

tasty, THANKS! That was a fast response too, way to go :slight_smile: I actually used

tail -n +2 myfile | head -1 | cut -c44-47

it said: Warning: "+number" syntax is deprecated, please use "-n +number"

The tail and head is very good, but.. with sed it is easy, too:

sed -n '2p;2q' file.txt | cut -c 44-47

With awk:

awk 'NR==2{print substr(44,4);exit}' file.txt