Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

bash script vs command line

Posted on 2004-11-22
6
Medium Priority
?
247 Views
Last Modified: 2010-04-17
Greetings Experts,

I am able to run the following from command line:
grep "1234 ABC\1.0" file.txt | grep ABCDEFGH01 | grep ALPHAONE | wc -l

When I attempt to do the same in a bash script, I don't get the same result.

How do I correct this?

TIA
0
Comment
Question by:uluttrell
5 Comments
 

Expert Comment

by:leitzler
ID: 12659150
If your bash-script is looking like this:

#!/bin/sh
grep "1234 ABC\1.0" file.txt | grep ABCDEFGH01 | grep ALPHAONE | wc -l

you should get the same result.. how does the results differ?
0
 

Author Comment

by:uluttrell
ID: 12660302
If i run the grep command the prompt i get the total number of occurrences.  If i run the grep command from within a script I get 0 as the result.
0
 
LVL 1

Expert Comment

by:Ortokobold
ID: 12663529
This '\1.0' equation looks strange to me...
Try to run: "grep ABCDEFGH01 file.txt | grep ALPHAONE | wc -l" both in command line and in script, and check the results.
If it works, the problem lies within the first equation.
0
 

Author Comment

by:uluttrell
ID: 12669827
Found the problem.  I had grep -c in the script that interfered with the wc -l.
0
 

Accepted Solution

by:
modulo earned 0 total points
ID: 12865223
PAQed with points refunded (150)

modulo
Community Support Moderator
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

577 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question