- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- How to capture * without automatic expansion
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
10-01-2003 06:55 AM
10-01-2003 06:55 AM
User enters: myprogram.sh *
I want to just capture the asterick (*), I don't want the filename expansion. Later in the program I use the * to help derive filenames from a different directory. How can I do this?
Example:
MYVAR=$*
if [ "X*" = "X${MYVAR}" ] ; then
ll -d /var/spool/lp/request/*
fi
I tried using set -f but it only does it for the current shell and not the script.
Thanks...
Jack...
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-01-2003 06:58 AM
10-01-2003 06:58 AM
Re: How to capture * without automatic expansion
set -o noglob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-01-2003 06:59 AM
10-01-2003 06:59 AM
Re: How to capture * without automatic expansion
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-01-2003 06:59 AM
10-01-2003 06:59 AM
Re: How to capture * without automatic expansion
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-01-2003 07:00 AM
10-01-2003 07:00 AM
Re: How to capture * without automatic expansion
or
myprogram.sh "*"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-01-2003 07:09 AM
10-01-2003 07:09 AM
Re: How to capture * without automatic expansion
find /dir -name "\*"
-or-
grep "\*" file
-or-
Use inode numbers.
ls -i (* write down inode number *)
find /dir -inum ### | awk ' { print $NF ) '
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-01-2003 07:57 AM
10-01-2003 07:57 AM
Re: How to capture * without automatic expansion
I tried setting the noglob / -f options in the script and it didn't work when I looked at the variable in the program. It still expanded.
thanks all...
Jack
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-01-2003 09:11 AM
10-01-2003 09:11 AM
Solutionecho myprogram *
Wow! myprogram now has a long list of filenames because the local shell expanded the list before myprogram even got started. This, the \* construct tells the CURRENT shell to stop any expansion on the next character. You can type this:
set -f
myprogram *
and it will work fine. BUT now something like ls *txt or echo *abc* will no longer produce any file matches because set -f turns of special character expansion permanently. This, the \* mechanism is the best choice. Another alternative is to tell users that anything besides alphanumerics should always be enclosed in quotes:
myprogram "*"
This tends to be more portable across other opsystems too (special characters require special handling).
Bill Hassell, sysadmin