- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: grep working differently
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
Discussions
Discussions
Forums
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
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
тАО02-01-2010 10:42 PM
тАО02-01-2010 10:42 PM
grep working differently
I am trying to connect oracle and get a date by using
YESDATE=`echo "select to_char(to_date('20100130', 'YYYYMMDD') - 1, 'YYYYMMDD') from dual;" | sqlplus -s ${CONNECT_STR} | grep [0-9]`
In my home directory it returns 20100129
but in our main directory it returns null since it tries to grep like 'grep 0 1'
Wonder why it grep like this instead of [0-9]
please help me out.
-Mayil
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-01-2010 11:55 PM
тАО02-01-2010 11:55 PM
Re: grep working differently
You first.
> but in our main directory it returns null
> since it tries to grep like 'grep 0 1'
How did you decide this? What do you get if
you leave off the "grep [...]"? That is,
what gets fed into the "grep" command?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-02-2010 02:03 AM
тАО02-02-2010 02:03 AM
Re: grep working differently
I tried this in command line
"echo "12string"|grep [0-9]"
It returns 12string in my home directory
but nothing when i do the same in main directory.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-02-2010 02:08 AM
тАО02-02-2010 02:08 AM
Re: grep working differently
What is for you the MAIN directory? If I were you I will check for environment variables to troubleshoot
# env in main and home directory
# whereis grep or which grep
After that get the location path of grep and test another time
# /usr/bin/grep
HTH
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-02-2010 04:15 AM
тАО02-02-2010 04:15 AM
Re: grep working differently
>in our main directory it returns null since it tries to grep like 'grep 0 1'
>Wonder why it grep like this instead of [0-9]
You haven't quoted it correctly, nor used $():
YESDATE=$(echo "select to_char(to_date('20100130', 'YYYYMMDD') - 1, 'YYYYMMDD') from dual;" | sqlplus -s ${CONNECT_STR} | grep "[0-9]")
In particular do the following in both directories:
echo "[0-9]"
echo [0-9]
>It returns 12string in my home directory but nothing when I do the same in main directory.
If you use tusc, you can see exactly what grep sees. And how the shell stabs you in the back. :-)
>Steven: >>grep like 'grep 0 1'
>How did you decide this?
That would be good to know. Either Mayil used tusc or Mayil is very clever on analyzing and providing test output.
In any case, it tells me a possible solution.