For example my file is like:59 6 18 2014 169 7 14 2 7671912 7849744 201 460 6 19 2014 170 5 49 2 7671912 7849744 201 561 6 20 2014 171 6 8 2 7671912 7849744 201 662 6 23 2014 174 5 3 2 7671912 7849744 201 763 6 23 2014 174 7 17 2 7671912 7849744 201 864 6 24 2014 175 16 13 2 7671912 7849744 201 965 6 25 2014 176 8 20 2 7671912 7849744 201 10101 1 49 6 16 2014 7 39 201 1 0 1043 <au_launchpad_back.gif> 201 gif <SIZE> 8711 2 49 6 17 2014 13 15 201 1 0 1043 <au_launchpad_back.gif> 201 gif <SIZE> 8711 3 49 6 18 2014 1 38 201 1 0 1043 <au_launchpad_back.gif> 201 gif <SIZE> 8711 4 49 6 18 2014 7 14 201 1 0 1043 <au_launchpad_back.gif> 201 gif <SIZE> 8711 5 49 6 19 2014 5 49 201 1 0 1043 <au_launchpad_back.gif> 201 gif <SIZE> 871I need to print the previous line of single token entry 10 which should be 65 6 25 2014 176 8 20 2 7671912 7849744 201 10How can I do this?
How to read the file line by line and to print the previous line where the file contains a single token
text processing
You can use awk:awk 'NF == 1 { print LAST } { LAST=$0 }' < datafileThis saves every line of the file (LAST=$0) as it goes, and when a line has only one record (NF == 1 - NF is the number of tokens on the line, roughly speaking) it prints the saved previous line out.