I know I have not solved using sed
or awk
or any of shell
commands, However tcl
did work out well.
I have kept the script simple and user friendly. elements like 4a abc
etc will be taken care
command
script.tcl file
Script
#!/usr/bin/tclsh
if {$argv == ""} {
puts "please enter the arguement"
exit ;
}
set tar_fl [lindex $argv 0]
if {![file exists $tar_fl]} {
puts "$tar_fl doesnot exist"
exit ;
}
set flptr [open $tar_fl r]
while {[gets $flptr line] >=0 } {
if {[llength $line] !=5} {continue ;}
if {[llength $line ] == 5} {
if {[lsearch -regexp $line {[^0-9]}]> -1} {continue;}
puts $line
}
}
close $flptr
Output
10 2 12 1 13
1 2 3 4 5