Sponsored Content
Top Forums Shell Programming and Scripting Help in grep function or similar using awk Post 302363467 by Lucky Ali on Tuesday 20th of October 2009 10:51:34 AM
Old 10-20-2009
Help in grep function or similar using awk

I have a list of id;

for example: file 1

dfghd
dfghe
dfgey
dfgeu

I have another data file that contain this ids as headers;

for ex. file2
>dfghd
gfdgfddl;klfkld;ld;lgl;dld'l'dv
>dfghe
gkwhjhsgdjdjdjhjddj
>dfgey
jdkjfhdjhfdkjhfdkhkdk

I wanted to compare file 1 and file 2 such a way that the output list the ids that are present in file 1 but not present in file 2.
For ex. the id 'dfgeu' is present in file 1 but its absent in file 2.

I want to have this id (dfgeu)which is missing in file 2 as header to be outputed.

Is there a way in awk to do this comparison of 2 files?

Please let me know.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

awk - Counting number of similar lines

Hi All I have the input file OMAK_11. OMAK 000002EXCLUDE 1341 OMAK 000002EXCLUDE 1341 OMAK 000002EXCLUDE 1341 OMAK 000003EXCLUDE 1341 OMAK 000003EXCLUDE 1341 OMAK 000003EXCLUDE ... (8 Replies)
Discussion started by: dhanamurthy
8 Replies

2. Shell Programming and Scripting

awk, sed or similar log repair help

I have a log file that for some reason, once or two time a month, line foods are missing. This log is generated from vmstat everyminute. I dont know why sometimes it does this. Each line in the log should have 18 columns separated by one or more spaces. Good Log: (not actual log) 1 1... (8 Replies)
Discussion started by: Ikon
8 Replies

3. Shell Programming and Scripting

Help with awk or something similar

i have a file like this: wedd01A1 1 wedd01A2 2 wedd01A3 1 wedd02A2 3 wedd02A3 4 wadd02A1 1 wadd02A2 5 wqdd01A1 3 wsdd01A3 1 i want out like this: A1 A2 A3 wedd01 1 2 1 wedd02 0 3 4 wadd02 1 5 0 wqdd01 3 0 0 wsdd01 0 0 1 (8 Replies)
Discussion started by: aydj
8 Replies

4. Shell Programming and Scripting

awk to search similar strings and add their values

Hi, I have a text file with the following content: monday,20 tuesday,10 wednesday,29 monday,10 friday,12 wednesday,14 monday,15 thursday,34 i want the following output: monday,45 tuesday,10 wednesday,43 friday,12 (3 Replies)
Discussion started by: prashu_g
3 Replies

5. Shell Programming and Scripting

awk to search similar strings and arrange in a specified pattern

Hi, I'm running a DB query which returns names of people and writes it in a text file as shown below: Carey, Jim; Cena, John Cena, John Sen, Tim; Burt, Terrence Lock, Jessey; Carey, Jim Norris, Chuck; Lee, Bruce Rock, Dwayne; Lee, Bruce I want to use awk and get all the names... (9 Replies)
Discussion started by: prashu_g
9 Replies

6. Shell Programming and Scripting

Using grep or something similar to invert search.

Hi guys, I have a script in which it simply do a grep of strings for the var/adm/messages file: NEWDATE=`TZ=GMT+1 date +%b" "%d" "%H` getalarm1=`grep "sent to primary BE" /var/adm/messages* | grep "$NEWDATE" | wc -l` getalarm2=`grep "CC-Request-Type 3 received in state Idle"... (5 Replies)
Discussion started by: matcam79
5 Replies

7. Shell Programming and Scripting

Add values of similar patterns with awk

so my output is this: session_closed=157 session_opened=151 session_closed=18 session_opened=17 there are two patterns here, but with different values. the two patterns are "session_opened" and "session_closed". i expect there will be many more other patterns. what i want to do is... (8 Replies)
Discussion started by: SkySmart
8 Replies

8. Shell Programming and Scripting

Optimizing for loop with awk or anything similar and portable

The variable COUNTPRO contains: COUNTPRO='Error__posting__message__to__EMR__Queue=0 Error__parsing__ReceiptSummary=0 xinetd__=4327 HTTP__1_1__500___=0 START__=2164 Marshaller__exception__while__converting__to__Receipt__xml=0 MessagePublisher__is__not__configured__correctly=0... (9 Replies)
Discussion started by: SkySmart
9 Replies

9. Shell Programming and Scripting

Need help on awk for printing the function name inside each function

Hi, I am having script which contains many functions. Need to print each function name at the starting of the function. Like below, functionname() { echo "functionname" commands.... } I've tried like below, func=`grep "()" scriptname | cut -d "(" -f1` for i in $func do nawk -v... (4 Replies)
Discussion started by: Sumanthsv
4 Replies

10. Shell Programming and Scripting

Vlookup using awk non similar files

I need to vlookup and check the server not found. Source file 1 server1 server2 server3 server4 server5_root server6_silver server7 server7-test server7-temp Source file 2 server1_bronze (6 Replies)
Discussion started by: ranjancom2000
6 Replies
XMLSTARLET(1)							 xmlstarlet Manual						     XMLSTARLET(1)

NAME
xmlstarlet - command line XML/XSLT toolkit SYNOPSIS
xmlstarlet [<options>] [<command>] [<cmd-options>] INTRODUCTION
XMLStarlet is a set of command line utilities (tools) which can be used to transform, query, validate, and edit XML documents and files us- ing simple set of shell commands in similar way it is done for plain text files using UNIX grep, sed, awk, diff, patch, join, etc commands. This set of command line utilities can be used by those who deal with many XML documents on UNIX shell command prompt as well as for auto- mated XML processing with shell scripts. OPTIONS
--version Display the version of xmlstarlet. --help Display help. COMMANDS
Type: xmlstarlet <command> --help <ENTER> for command help Available commands include: ed (or edit) Edit/update XML document(s). sel (or select) Select data or query XML document(s) (XPATH, etc). tr (or transform) Transform XML documents(s) using XSLT. val (or validate) Validate XML document(s) (well-formed/DTD/XSD/RelaxNG). fo (or format) Format XML document(s). el (or elements) Display element structure of XML document. c14n (or canonic) XML canonicalization. ls (or list) List directory as XML. esc (or escape) Escape special XML characters. unesc (or unescape) Unescape special XML characters. pyx (or xmln) Convert XML into PYX format (based on ESIS - ISO 8879). p2x (or depyx) Convert PYX into XML. REFERENCES
XMLStarlet is a command line toolkit to query/edit/check/transform XML documents (for more information see http://xmlstar.source- forge.net/). AUTHOR
Mikhail Grushinskiy. XMLSTARLET(1)
All times are GMT -4. The time now is 12:41 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy