Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Issue when using egrep to extract strings (too many strings) Post 302971523 by forevertl on Thursday 21st of April 2016 10:46:15 AM
Old 04-21-2016
Thank you guys. I tried the code below and it works.
Code:
awk 'NR==FNR {A[$1]; next} ($1 in A)' stringfile test1>test2

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Delete strings in file1 based on the list of strings in file2

Hello guys, should be a very easy questn for you: I need to delete strings in file1 based on the list of strings in file2. like file2: word1_word2_ word3_word5_ word3_word4_ word6_word7_ file1: word1_word2_otherwords..,word3_word5_others... (7 Replies)
Discussion started by: roussine
7 Replies

2. Shell Programming and Scripting

How to Extract text between two strings?

Hi, I want to extract some text between two strings in a line i am using following command i.e; awk '/-string1/,/-string2/' filename contents of file is--- line1 line2 aaa -bbb -ccc -string1 c,d,e -string2 line4 but it is showing complete line which is having searched strings. aaa... (19 Replies)
Discussion started by: emresearch
19 Replies

3. Shell Programming and Scripting

Delete lines in file containing duplicate strings, keeping longer strings

The question is not as simple as the title... I have a file, it looks like this <string name="string1">RZ-LED</string> <string name="string2">2.0</string> <string name="string2">Version 2.0</string> <string name="string3">BP</string> I would like to check for duplicate entries of... (11 Replies)
Discussion started by: raidzero
11 Replies

4. Shell Programming and Scripting

Egrep strings on different lines in file

test.txt: appleboy orangeletter sweetdeal catracer conducivelot I want to only grep out lines that contain "appleboy" AND "sweetdeal". however, the closest thing to this that i can think of is this: cat test.txt | egrep "appleboy|sweetdeal" problem is this only searches for all... (9 Replies)
Discussion started by: SkySmart
9 Replies

5. Shell Programming and Scripting

Extract two strings from a file and create a new file with these strings

I have the following lines in a log file. It would be great if some one can help me to create a new file with the just entries in the below format. 66.150.161.195 HPSAC=Z05 66.150.161.196 HPSAC=A05 That is just extract the IP address and the string DPSAC=its value 66.150.161.195 -... (1 Reply)
Discussion started by: Tuxidow
1 Replies

6. UNIX for Dummies Questions & Answers

Extract code between 2 strings.

Hi, Im having some problems with this. I have loaded a file with html code. All code is placed in the same line. I want to get everything between two given strings (including these strings and get only the first appearance). Example: File contains <html><body><a href='a.html'>abc</a><a... (5 Replies)
Discussion started by: ngb
5 Replies

7. Shell Programming and Scripting

Exclude lines in a file with matches with multiple Strings using egrep

Hi I have a txt file and I would like to use egrep without using -v option to exclude the lines which matches with multiple Strings. Let's say I have some text in the txt file. The command should not fetch lines if they have strings something like CAT MAT DAT The command should fetch me... (4 Replies)
Discussion started by: Sathwik
4 Replies

8. UNIX for Beginners Questions & Answers

How to pass strings from a list of strings from another file and create multiple files?

Hello Everyone , Iam a newbie to shell programming and iam reaching out if anyone can help in this :- I have two files 1) Insert.txt 2) partition_list.txt insert.txt looks like this :- insert into emp1 partition (partition_name) (a1, b2, c4, s6, d8) select a1, b2, c4, (2 Replies)
Discussion started by: nubie2linux
2 Replies

9. UNIX for Beginners Questions & Answers

Extract content between strings

Hello i am stuck with this. i have input which is as follows /type/work /works/OL10627594W 3 2019-04-24T16:46:21.351549 {"created": {"type": "/type/datetime", "value": "2009-12-11T03:18:17.488715"}, "title": "Tog the dog", "covers": , "last_modified": {"type":... (3 Replies)
Discussion started by: ahfze
3 Replies

10. Shell Programming and Scripting

Extract strings from output

I am having the following output when executing a dig command : dig @1.1.1.1 google.com +noall +answer +stats ; <<>> DiG 9.11.4-P1 <<>> @1.1.1.1 google.com +noall +answer +stats ; (1 server found) ;; global options: +cmd obodrm.prod.at.dmdsdp.com. 86154 IN A ... (1 Reply)
Discussion started by: liviusbr
1 Replies
xstr(1) 						      General Commands Manual							   xstr(1)

NAME
xstr - Extracts strings from C programs to implement shared strings SYNOPSIS
xstr [-c] [file | -] The xstr command maintains a file called strings into which strings in component parts of a large program are hashed. OPTIONS
Extracts strings from the specified file. DESCRIPTION
The strings extracted by xstr are replaced with references to this array. This serves to implement shared constant strings, most useful if they are also read-only. The following command extracts the strings from the C source in file, replacing string references by expressions of the form (&xstr[num- ber]) for some number. xstr -c file The xstr command uses file as input; the resulting C text is placed in the file x.c to then be compiled. The strings from this file are appended to the strings file if they are not there already. Repeated strings and strings that are suffixes of existing strings do not cause changes to the file. If a string is a suffix of another string in the file, but the shorter string is seen first by xstr, both strings are placed in the file strings. After all components of a large program are compiled, a file xs.c declaring the common xstr space can be created by a command of the fol- lowing form: xstr Compile and load this xs.c file with the rest of the program. Some C compilers may, by default, put strings in a read-only text section. The xstr command can also be used on a single file. The following command creates files x.c and xs.c as before, without using or affecting a strings file in the same directory. xstr file It may be useful to run xstr after the C preprocessor if any macro definitions yield strings or if there is conditional code that contains strings that may not be needed. The xstr command reads from its standard input when the argument - (dash) is given. An appropriate command sequence for running xstr after the C preprocessor is as follows: cc -E file.c | xstr -c - cc -c x.c mv x.o file.o The xstr command does not touch the file strings unless new items are added, thus make can avoid remaking xs.o unless truly necessary. EXAMPLES
To extract the strings from the C source in the file.c parameter, replacing string references by expressions of the form (&xstr[number]), enter: xstr -c file An appropriate declaration of the xstr array is prepended to file. The resulting C text is placed in the file x.c, to then be com- piled. To declare the common xstr array space in the xs.c file, enter: xstr FILES
File that contains the extracted strings. Modified C source. C source for definition of array xstr. Temporary file when the xstr command does not touch strings. SEE ALSO
Commands: mkstr(1) xstr(1)
All times are GMT -4. The time now is 08:18 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy