Tag Archives: BARUHUHFD

Grep the 5th and 6th position character of a word in a file

By e_mikey_2000

I am trying to find/grep the 5th and 6th position character (TX) of a word in a file. I tried to do
grep “….TX” file
The output gives me everything in the file with TX in it. I only need the output with the TX in the 5th and 6th position of the word. Any idea

Example:

test1 car CARYTXKJH 4632 car
test2 truck TRUCKKTXH 736 truck
dir655 van VANTTXMPO 23 van
test4 mini BNTVTXGFA 23 mini
bar123 bus BARUHUHFD
file2 plane FTSMAMGYU 23 plane

output file
test1 car CARYTXKJH 4632 car
dir655 van SPDLTXMPO 23 van
test4 mini BNTVTXGFA 23 mini

———- Post updated at 01:00 PM ———- Previous update was at 12:56 PM ———-

The output file should be:

test1 car CARYTXKJH 4632 car
dir655 van VANTTXMPO 23 van
test4 mini BNTVTXGFA 23 mini

…read more

Source: FULL ARTICLE at The UNIX and Linux Forums