|
|||||||
| Forums | Search Forums | Register | Forum Rules | Man Pages | Albums | FAQ | Members | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
||||
|
||||
|
I have two sets of data accept.txt is the list of 50 words Code:
Tom Anne James ... and I have a file01.txt which has the frequency of words which I got it using Code:
cat main.file | tr -d '[:punct:]' | tr ' ' '\n' | tr 'A-Z' 'a-z' | sort | uniq -c | sort -n -r > file01.txt so my file now looks like this Code:
155 the 100 a 55 this 34 Anne 5 James I need the output to look like this Code:
0 34 5 I tried using grep but dont know how to replace things with 0 and just print one column Code:
for name in `cat accept.txt ` do grep $name file01.txt; done I have to do this for 20 files in the same folder and would like to eventually print it as
can someone please help me? Thank you in advance for your time |
| Sponsored Links | ||
|
|
#2
|
|||
|
|||
|
Try this script: Code:
#!/bin/ksh
ls file* | sort | tr '\n' '\t' | sed 's/^/\t/g'
echo ""
for name in `cat accept.txt`
do
printf "${name}"
for i_file in `ls file* | sort`
do
count=`grep -c "${name}" "${i_file}"`
printf "\t${count}"
done
echo""
done |
| Sponsored Links | ||
|
|
#3
|
|||
|
|||
|
Thanks for the help... I find a solution for if but yours look much more pro
![]() |
| Sponsored Links | ||
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| script to grep a pattern from file compare contents with another file and replace | namitai | Shell Programming and Scripting | 2 | 08-30-2011 01:31 PM |
| Grep a pattern given in one file at other file and display its corresponding contents as output. | abinash | Shell Programming and Scripting | 7 | 02-23-2011 01:51 AM |
| Grep pattern from different file and display if it exists in the required file | abinash | Shell Programming and Scripting | 3 | 12-08-2010 08:20 AM |
| Grep a pattern in gz file | rprajendran | UNIX for Dummies Questions & Answers | 2 | 12-01-2008 01:27 PM |
| Grep pattern problem | mojoman | UNIX for Dummies Questions & Answers | 1 | 11-26-2008 10:50 AM |
|
|