05-23-2012
QUESTION1: grep only exact string. QUESTION2: find and replace only exact value with sed
QUESTION1:
How do you grep only an exact string. I am using Solaris10 and do not have any GNU products installed.
Contents of car.txt
CAR1_KEY0
CAR1_KEY1
CAR2_KEY0
CAR2_KEY1
CAR1_KEY10
CURRENT COMMAND LINE: WHERE VARIABLE CAR_NUMBER=1 AND KEY_NUMBER=1
grep ^CAR$CAR_NUMBER"_KEY"$KEY_NUMBER car.txt
OUTPUT:
CAR1_KEY1
CAR1_KEY10
OUTPUT WANTED (HOW DO I ONLY GET THIS):
CAR1_KEY1
QUESTION2:
I have a similar problem with sed (find and replace) using the same input file car.txt.
COMMAND LINE: WHERE VARIABLE CAR_VALUE=1000
sed 's/^CAR'$CAR_NUMBER'_KEY'$KEY_NUMBER'.*/CAR'$CAR_NUMBER'_KEY'$KEY_NUMBER' '$CAR_VALUE'/1' car.txt > new_car.txt
OUTPUT:
CAR1_KEY0
CAR1_KEY1 1000
CAR2_KEY0
CAR2_KEY1
CAR1_KEY1 1000
OUTPUT WANTED (HOW DO I ONLY GET THIS):
CAR1_KEY0
CAR1_KEY1 1000
CAR2_KEY0
CAR2_KEY1
CAR1_KEY10
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
Hi,
Can anyone help me with the text editing I need here. I have a file that contains the following lines for example: (line numbers are for illustration only)
1 Hello world fantasy.
2 Hello worldfuntastic.
3 Hello world wonderful.
I would like to get all those lines of text that... (5 Replies)
Discussion started by: risk_sly
5 Replies
2. Shell Programming and Scripting
Hi experts,
As i am a novice unix player...so need help for the below query...banged my head from quite a while...:confused:
i have a set of html files, in which i need to search for string "Page"(case sensitive) and then replace the same with some numeric code ,say, "XXX1234".
Here in... (1 Reply)
Discussion started by: rahulfhp
1 Replies
3. Shell Programming and Scripting
Hi there,
I've search this forum and find this problem could have been solved by,
grep -ho "num=*" input_data
The input_data is,
1\11\num1=100\num2=200\newnum1=220\\@
however, what I have got is ,
num1=100
num1=220
how to get the exact string, (4 Replies)
Discussion started by: liuzhencc
4 Replies
4. Shell Programming and Scripting
Hello Everyone,
Im trying to run a search and replace of exact strings and the strings that im using variables that are passed through an array in a while loop. Here is a snip of my code:
USEROLD=`cat oldusers`
USERNEW=`cat newusers`
USEROLDARRAY=( $USEROLD )
USERNEWARRAY=( $USERNEW )... (4 Replies)
Discussion started by: skizim
4 Replies
5. Shell Programming and Scripting
I have a file
DS1
DDS
DS
I want to replace only "DS" to "DSmail.blah.com" in a lot of files. I tried
sed 's/DS/DSmail.blah.com' but it changes all the lines .
thanks in advance (2 Replies)
Discussion started by: gubbu
2 Replies
6. Shell Programming and Scripting
Hi,
I have the following output from a file
zone "adm.test.com" {
abc
test1.db
}
zone "test.com" {
xyz
test2.db
}
zone "1.test.com.sg" {
1abc
test3.db
}
zone "3.test.com.uk" {
1xyz
test4.db
} (6 Replies)
Discussion started by: vchee
6 Replies
7. Shell Programming and Scripting
All,
I am trying to read in a variable and search a file then delete based on that string, but i want to match exact word.
This works but it matches all, i don't want to match anthing that contains the string, just the exact string.
sed -i "/$feedname/d" file
I tried
sed... (1 Reply)
Discussion started by: markdjones82
1 Replies
8. UNIX for Dummies Questions & Answers
Hi All,
I have a text / log file which contains strings like meta777, 77, meta, 777. Now I want to write a script which can detect a string 'meta#777' in a text file & number of occurence of 'meta', number of #, number 7, 77, 777.
I'm using grep -e '77' filename but no luck. It is returning... (5 Replies)
Discussion started by: adc22
5 Replies
9. Shell Programming and Scripting
Hi all,
I tried searching the forum for this, and I read numerous suggestions here and even on other forums, and I cannot get this to want the way that I need it to. I tried grep -W / -f to no luck. Here is what I have. I have a list of file names-
FILE1-FILE1TEST,FILE1RELATION... (7 Replies)
Discussion started by: jeffs42885
7 Replies
10. Shell Programming and Scripting
I have a file change.sed
more change.sed
I fire the below command inorder to replace "190.169.11.15" with "10.4.112.240" in proxy.logsed -f change.sed proxy.log proxy.log has the below entry
more proxy.log
The command replaces both 190.169.11.15 & 190.169.11.155 as below:
I am expecting... (17 Replies)
Discussion started by: mohtashims
17 Replies
LEARN ABOUT DEBIAN
urls_txt
URLS.TXT(5) File Formats Manual URLS.TXT(5)
NAME
urls.txt - URL database for regression testing
INTRODUCTION
The urls.txt file is installed by default in /etc/siege/urls.txt. When siege is invoked without a command line reference to a URL, then by
default it looks for urls in that file. The advantage of using the urls.txt file is two-fold: One, it frees you free retyping a url with
every invocation. And two, it allows you to conduct full site regression testing.
When the urls.txt file is used, siege reads all the urls in that file into memory and runs through the list in one of two ways, sequen-
tially or randomly. The default run is sequential from start to finish and back again until the --reps or the --time option has been satis-
fied. With the -i/--internet option selected, siege runs through the file randomly simulating the stress applied by a community of inter-
net users.
The -f/--file option allows you to select a file other then the default urls.txt file. You may also instruct siege to use a different file
with the "file" directive in .siegerc, i.e., "file = /usr/local/etc/urls.txt"
You may set and reference variables inside the urls.txt file. All variables must be declared BEFORE they are referenced. Variables are
declared with the "=" operator, VARIABLE = VALUE. They are then referenced inside $() or ${}, example: $(HOST), ${HOST}
HOST=joey.joedog.org
http://${HOST}/browse.jsp?size=5
http://${HOST}/admin.jsp?name=ralph
EXAMPLE FILE
This is an exmple urls.txt file. Lines beginning with a hash (#) are comments and ignored by siege.
#
# Example urls.txt file
# URLs database for siege
#
http://www.haha.com/index.html
http://www.haha.com/howto/index.html
http://www.haha.com/cgi-bin/howto/display.cgi?1013
www.haha.com/cgi-bin/fm.cgi?first=j.&last=fulmer
https://www.haha.com/index.shtml
https://www.whoohoo.com/my_whoohoo.jsp
# POST data requires a POST directive
www.haha.com/cgi-bin/foo.cgi POST first=bart&last=simpson
www.haha.com/hoho.jsp POST name=jeff&pass=secret
# POST the contents of a file using the
# line input character "<"
http://www.haha.com/my.jsp POST </home/jeff/data.txt
AUTHOR
Jeffrey Fulmer <jeff@joedog.org>, et al.
BUGS
Report bugs to jeff@joedog.org. Give a detailed description of the problem and report the version of siege that you are using.
COPYRIGHT
Copyright (C) 2007 Jeffrey Fulmer, et al.
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MER-
CHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation,
Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
AVAILABILITY
The most recent released version of siege is available by anonymous FTP from ftp.joedog.org in the directory pub/siege.
SEE ALSO
siege(1) siege.config(1) layingsiege(7)
Siege v2.70 April-17-2012 URLS.TXT(5)