I have a huge file of hashes that is displayed like this:
username:values:values:password hash:::
username:values:values:password hash:::
username:values:values:password hash:::
Examples of usernames i want to put into a new file:
Y783071:SDF87DSFQ1:DSF98D3EF:DSF98SDF98
G678876:SD8F7SD8F7:DF98SDF89:SDF98S
J110998:SDF98FJ98W:9J493H0L8:3498RJHT
You can use below sed command:
sed -n '/^[a-zA-Z]\{1\}[0-9]\{6\}:/p' hash_file > output_file
This sed command looks for lines starting with 1 alphabet ( [a-zA-Z]\{1\}
) followed by 6 numbers ( [0-9]\{6\}
) followed by :
.