Hello folks i have file which is below, i want to extract last column of file that contains dm-21 or dm-13 or dm-N
it show output like
I have tried but i got this
Hello folks i have file which is below, i want to extract last column of file that contains dm-21 or dm-13 or dm-N
it show output like
I have tried but i got this
echo 'Aug 5 04:15:32 server kernel: ournald(4108): WRITE block 15661624 on dm-21' | sed 's/.*[ ]//'
awk '$NF ~ /dm-[0-9]/{print $NF}' file
perl -lane 'if($_=~/dm-21|dm-13|dm-N/){print $F[-1]}' /var/log/messages
It is showing output like this
It is showing output like this
which command you tried ?
Not working properly giving only. many characters are missing.
as i mentioned i need output like this
what you mean by many characters are missing ?
you want the entire line ? ( instead of last field ? )
following columns are missing, yes true i need last column but only start with dm and end on number not garbage character as well.
in your original question you asked
Hello folks i have file which is below, i want to extract last column of file that contains dm-21 or dm-13 or dm-N
if you want to just match the last column with dm-<any number> then try the following
perl -lane 'print $F[-1] if($F[-1]=~/dm-[0-9]/)' input.txt
Thanks but garbage is also coming, your this command is correct but how to remove garbage.
sed 's/.*\(dm-[0-9][0-9]*\)$/\1/' myFile
try this...
perl -lane 'print $1 if($_=~m/(dm-[0-9]+$)/)' input.txt
Thanks so much both of you.
awk 'match($NF,/dm-[0-9]*$/){print substr($0,RSTART,RLENGTH)}' input.txt
That is printing only first column which is
unless and until you provide a representative and consistent (not changing between posts) set of the sample files, it will be difficult to provide help.