- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- multiple variable search
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-25-2003 11:13 PM
11-25-2003 11:13 PM
multiple variable search
we have a file with x amount of lines, on each line are numbers(ie. 1234 7896) and we need to search through all occurrences
of when these 2 numbers appear? So both numbers MUST appear in each record. Our script can only read one variable/number
and not both. Does anyone know how we could read 2 variables into a file search?
cat numbers.list | while read num1 num2
do
gzcat filename*.gz | grep $num1 > data_extract.log
done
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-25-2003 11:25 PM
11-25-2003 11:25 PM
Re: multiple variable search
a bit primitive, change the line:
gzcat filename*.gz | grep $num1 > data_extract.log
to
gzcat filename*.gz | grep "$num1" | grep "$num2" > data_extractlog
regards,
John K.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-25-2003 11:29 PM
11-25-2003 11:29 PM
Re: multiple variable search
grep -i "1234" input_file > /tmp/file.txt
grep -i "7896" input_file >> /tmp/file.txt
for i in `cat /tmp/file.txt`
do
echo $i|grep "1234"|grep "7896"
if [ $? -eq 0]
then
echo $i > /tmp/final.txt
exit
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-25-2003 11:31 PM
11-25-2003 11:31 PM
Re: multiple variable search
cat input_file|grep -i "1234"|grep -i "7896"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-26-2003 12:57 AM
11-26-2003 12:57 AM
Re: multiple variable search
regards,
John K.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-26-2003 01:13 AM
11-26-2003 01:13 AM
Re: multiple variable search
Something like:
TMPF=/tmp/whatever.${$}
rm -f data_extract.log
gzcat filename > ${TMPF}
cat numbers.list | {
while read num1 num2
do
grep "${num1}.*${num2}" ${TMPF} >> data_extract.log
done
}
rm ${TMPF}
Regards,
John
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-26-2003 01:19 AM
11-26-2003 01:19 AM
Re: multiple variable search
We have an input file (input.lst) containing numbers & we have approx. 200 comma separated files.What we want to do
is search for the occurence of each number in the input file in the comma separated file & extract the entire record.
The input file looks like:
12345,6789
43212,09878
.
.
.
.
.
.
.
.
6543218,4253759
etc. Any ideas how this extract could be achieved?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-26-2003 01:33 AM
11-26-2003 01:33 AM
Re: multiple variable search
IFS=,
cat input.lst | {
while read num1 num2
...
Need some more info and examples of what you want to do though.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-26-2003 01:36 AM
11-26-2003 01:36 AM
Re: multiple variable search
egrep "${num1}.*${num2}|${num2}.*${num1}"
Or if the file is comma seperated:
egrep "${num1},${num2}|${num2},${num1}"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-26-2003 01:54 AM
11-26-2003 01:54 AM
Re: multiple variable search
try this
cat numbers.list | while read num1 num2
do
gzcat filename*.gz | grep -E ".*$num1.*$num2|.*$num2.*$num1" > data_extract.log
done
greetings,
Michael
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-26-2003 01:56 AM
11-26-2003 01:56 AM
Re: multiple variable search
in case the numbers are as show, you can use
gzcat filename*.gz | grep -E ".*$num1,$num2|.*$num2,$num1" > data_extract.log
greetings,
Michael
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-26-2003 02:27 AM
11-26-2003 02:27 AM
Re: multiple variable search
Edgar
Not sure if I've understood.
My solution looks nothing like any other, so probably not.
In your initial post you are looking for pairs of numbers, later you talk about them coming from input.lst
I would try awk, using the BEGIN clause to read in your numbers file, then processing all other files, comparing against the lists.
It is horribly inefficient.
Create a file, say edgar.awk, containing
--
BEGIN {
pairs=0
do {
eof = getline < "input.lst"
if (eof == 1) {
n=split ($0,pair,",")
if (n==2) {
pairs++
number1 [pairs]=pair[1]
number2 [pairs]=pair[2]
}
}
} while (eof == 1)
}
{
for (i=1;i<=pairs;i++) {
if (($0 ~ number1[$i]) && ($0 ~ number2[$i])) {
next
}
}
}
--
and invoke with awk -f edgar.awk *.csv (where *.csv represents your comma separated files.
I think from your earlier example that this might be
gzcat filename*.gz | awk -f edgar.awk
-- Graham
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-27-2003 12:21 AM
11-27-2003 12:21 AM
Re: multiple variable search
if the problem is solved, could you spare some points from the endless supply of points, HP has, for those, who could help you? ;-)
greetings,
Michael