Sponsored Content
Full Discussion: file preprocessing
Top Forums Shell Programming and Scripting file preprocessing Post 302270846 by reddyrajal on Tuesday 23rd of December 2008 02:42:09 AM
Old 12-23-2008
try this

cat file
2 a b c
2 g h i
3 l k m
3 o p a
4 r t f

awk '{print $1}' file | sort -u | while read line; do grep ^$line file | tail -1 ; done
2 g h i
3 o p a
4 r t f

this will works even the first feild is not a digit

Last edited by reddyrajal; 12-23-2008 at 04:49 AM..
 

4 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

AWK and preprocessing

Hello , I'm trying to to write simple ANSI C preprocessor but I have problem with recursive call. When I call my function : preproc(filename) , I get message " Segmentation fault Core Dumped : " . Please Help Paweł Łepko Hire Is My Code : #!/usr/bin/nawk -f #Autor :... (4 Replies)
Discussion started by: scotty_123
4 Replies

2. Shell Programming and Scripting

Match list of strings in File A and compare with File B, C and write to a output file in CSV format

Hi Friends, I'm a great fan of this forum... it has helped me tone my skills in shell scripting. I have a challenge here, which I'm sure you guys would help me in achieving... File A has a list of job ids and I need to compare this with the File B (*.log) and File C (extend *.log) and copy... (6 Replies)
Discussion started by: asnandhakumar
6 Replies

3. Shell Programming and Scripting

Compare 2 text file with 1 column in each file and write mismatch data to 3rd file

Hi, I need to compare 2 text files with around 60000 rows and 1 column. I need to compare these and write the mismatch data to 3rd file. File1 - file2 = file3 wc -l file1.txt 58112 wc -l file2.txt 55260 head -5 file1.txt 101214200123 101214700300 101250030067 101214100500... (10 Replies)
Discussion started by: Divya Nochiyil
10 Replies

4. Shell Programming and Scripting

Shell script (sh file) logic to compare contents of one file with another file and output to file

Shell script logic Hi I have 2 input files like with file 1 content as (file1) "BRGTEST-242" a.txt "BRGTEST-240" a.txt "BRGTEST-219" e.txt File 2 contents as fle(2) "BRGTEST-244" a.txt "BRGTEST-244" b.txt "BRGTEST-231" c.txt "BRGTEST-231" d.txt "BRGTEST-221" e.txt I want to get... (22 Replies)
Discussion started by: pottic
22 Replies
0intro 0intro intro 0intro 2a 2a 6a 2a 8a 2a ka 2a va 2a xa 2a 2c
2c 6c 2c 8c 2c kc 2c vc 2c xc 2c 2l 2l 6l 2l 8l 2l kl 2l vl 2l xl
2l 81/2 81/2 label 81/2 window 81/2 wloc 81/2 acid acid acme acme
awd acme win acme 8al alef alef alef kal alef val alef ar ar  art
art  art2pic art ascii ascii unicode ascii awk awk basename base-
name bc bc bind bind mount bind unmount bind  bundle  bundle  c++
c++ c++/2c c++ c++/2l c++ c++/8c c++ c++/8l c++ c++/kc c++ c++/kl
c++ c++/vc c++ c++/vl c++ cal cal calendar calendar cat cat  read
cat  char  char  rschar char 1/2char char chgrp chgrp chmod chmod
cmp cmp comm comm con con cu con rx con telnet con  xmr  con  xms
con cp cp mv cp cpp cpp cpu cpu date date db db dc dc dd dd dela-
tex deroff deroff deroff diff diff doctype  doctype  du  du  echo
echo  ed  ed emacs emacs eqn eqn factor factor primes factor file
file fmt fmt fone fone fortune fortune	freq  freq  4s	games  5s
games  ana  games  catclock games clock games festoon games fire-
works games fsim games games games life games mandel games  plumb
games  smiley games swar games grap grap graph graph grep grep gs
gs hoc hoc hp hp join join broke kill kill kill ktrans ktrans lex
lex  look  look lp lp lc ls ls ls aliasmail mail edmail mail mail
mail seemail mail sendmail mail smtp mail smtpd mail to mail vis-
mon  mail  vwhois mail lookman man man man mc mc membername mk mk
mk mkdir mkdir mothra mothra netstat netstat news news nm nm p	p
page  page  netkey  passwd passwd passwd pcc pcc pic pic tpic pic
plot plot ppp ppp pppclient ppp pppserver ppp pr  pr  kprof  prof
prof  prof proof proof ps ps psu ps pbd pwd pwd pwd cd rc eval rc
exec rc exit rc flag rc rc rc rfork rc shift rc wait rc whatis rc
~  rc  rm rm B sam sam sam sam.save sam sed sed seq seq size size
sleep sleep sort sort spell spell sprog  spell	spin  spin  split
split start stop stop stop strings strings strip strip md5sum sum
sum sum syscall syscall tail  tail  32vfs  tapefs  cpiofs  tapefs
tapefs	tapefs tapfs tapefs tarfs tapefs tpfs tapefs v10fs tapefs
v6fs tapefs tar tar tbl tbl tcs tcs tee tee iwhois  tel  tel  tel
test test bibtex tex dvips tex dviselect tex latex tex mf tex tex
tex time time touch touch tr tr nroff  troff  troff  troff  tweak
tweak twig twig uniq uniq units units ki vi vi vi xi vi wc wc who
who whois who xd xd yacc yacc yesterday yesterday
All times are GMT -4. The time now is 09:14 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy