03-20-2009
How to find the lines which do not have certain strings
Hi, guys. I have one question:
How can I search the lines in a file which do not have certain string in it.
For example, the file is called shadow, the contents of it is below:
****************************
...
brownj:SFSM$DFAAA2313:0:0:50:7
hynesp:MNBADF$23$adfd:0:0:50:7
dioxna:SFTDFAAR#$313:0:0:50:7
sherrys:added_string_SFSM$ASDFG313:0:0:50:7
...
****************************
How can I find all the lines which do not have string "padding_string" and assign them to a variable?
The code is below, but it doesn't work
$var=$(grep -G "!:added_string" shadow)
Can any body help me with this?
Thank you very much for your time in advance
-Keyang
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hello all,
I am having trouble with setting up a regular expression used with egrep. My script reads an input file a line at a time. I would like the egrep command to search for the following pattern: server name at the beginning of the line, then one or more spaces, and then a pound sign.
... (5 Replies)
Discussion started by: Galt
5 Replies
2. Shell Programming and Scripting
Hi experts,
You cool guys already given me the awk script below-
awk '/9366109380/,printed==5 { ++printed; print; }' 2008-09-14.0.log
Morever, i have one more things-
when i awk 9366109380, i can also see the Upper 3 lines as well as below 5 lines of that string.
Line 1.... (3 Replies)
Discussion started by: thepurple
3 Replies
3. Shell Programming and Scripting
Hi
I am writing a script which should read a file and search for certain strings 'approved' or 'removed' and retain only those lines that contain the above strings.
Ex: file name 'test'
test:
approved package
waiting for approval package
disapproved package
removed package
approved... (14 Replies)
Discussion started by: vj8436
14 Replies
4. Shell Programming and Scripting
Hi,
Please provide shell script to Remove empty lines(space) between two lines containing strings in a file.
Input File :
A1/EXT "BAP_BSC6/07B/00" 844 090602 1605
RXOCF-465 PDTR11 1
SITE ON BATTERY
A2/EXT... (3 Replies)
Discussion started by: sudhakaryadav
3 Replies
5. Shell Programming and Scripting
How can i find lines which contains two strings (or two charcters) let say "ABC" and "DEF".
Line: SEFGWN;BVABCFSDFBDEF (3 Replies)
Discussion started by: ksailesh
3 Replies
6. UNIX for Dummies Questions & Answers
I want to search files (basically .cc files) in /xx folder and subfolders.
Those files (*.cc files) must contain #include "header.h" AND x() function.
I am writing it another way to make it clear,
I wanna list of *.cc files that have 'header.h' & 'x()'. They must have two strings, header.h... (2 Replies)
Discussion started by: ritikaSharma
2 Replies
7. Shell Programming and Scripting
What's the easiest way to search a file for a specific string and then look for other instances after that? I want to search for all Virtual Hosts and print out the Server Name and Document Root (if it has that info), while discarding the rest of the info.
Basically my file looks like this:
...... (6 Replies)
Discussion started by: Mbohmer
6 Replies
8. Shell Programming and Scripting
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
9. Shell Programming and Scripting
I have a .txt contains a lot of lines.
Now I want to write a shell script to find out all the lines which contain the strings I want, and print these lines.
For example:
A.txt
when you post any code
you can easily do this
highlighting your code and then click
you should do a Google... (6 Replies)
Discussion started by: Henryyy
6 Replies
10. Solaris
Hello,
I have spent considerable amount of time breaking my head on this and reached out here. here is the back ground.
OS - Solaris 10
There are two strings '<Orin>sop' and '<Dup>two' which I wanted to look for in a file without the quotes on different lines and ONLY if both strings are... (5 Replies)
Discussion started by: keithTait309875
5 Replies
LEARN ABOUT DEBIAN
plan9-look
LOOK(1) General Commands Manual LOOK(1)
NAME
look - find lines in a sorted list
SYNOPSIS
look [ -dfnixtc ] [ string ] [ file ]
DESCRIPTION
Look consults a sorted file and prints all lines that begin with string. It uses binary search.
The following options are recognized. Options dfnt affect comparisons as in sort(1).
-i Interactive. There is no string argument; instead look takes lines from the standard input as strings to be looked up.
-x Exact. Print only lines of the file whose key matches string exactly.
-d `Directory' order: only letters, digits, tabs and blanks participate in comparisons.
-f Fold. Upper case letters compare equal to lower case.
-n Numeric comparison with initial string of digits, optional minus sign, and optional decimal point.
-t[c] Character c terminates the sort key in the file. By default, tab terminates the key. If c is missing the entire line comprises the
key.
If no file is specified, /lib/words is assumed, with collating sequence df.
FILES
/lib/words
SOURCE
/src/cmd/look.c
SEE ALSO
sort(1), grep(1)
DIAGNOSTICS
The exit status is ``not found'' if no match is found, and ``no dictionary'' if file or the default dictionary cannot be opened.
LOOK(1)