Reputation: 1135
Was wondering how you print/obtain the first character in a text file in unix.
i.e say "9 textfile.txt" would return 9
thx
Upvotes: 1
Views: 8804
Reputation: 161954
You can use head
to get first char of file:
head -c 1 file.txt
If you want first char of every line:
grep -o ^. file.txt
Or
cut -c 1 file.txt
Upvotes: 8