![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Help how replace stardard keyboard inputs by arguments at run time of a script | Dingrong | UNIX for Dummies Questions & Answers | 6 | 10-14-2008 04:46 AM |
| Help in passing array of inputs to C program using script? | ahjiefreak | Shell Programming and Scripting | 1 | 03-20-2008 07:36 AM |
| Passing blank arguments to a script | rm-r | UNIX for Advanced & Expert Users | 7 | 01-08-2008 08:56 PM |
| Shell script with arguments | sankar6254 | Shell Programming and Scripting | 3 | 12-22-2003 09:21 AM |
| Passing arguments to a script | Kevin Pryke | Shell Programming and Scripting | 3 | 06-14-2002 10:06 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
You can test, if the script was called with an argument:
[[ -z "$@" ]] && printf "No input\n" || printf "Input: %q\n" "$@" Which means: if the length of the arguments ( $@) is zero (-z) then print "No input" else print the string in escaped form. I don't not, what you want to achieve, but if you try to escape strings, check the %q option of printf. If you call the testscript this way: testscript "h's m" it will give you: Input: h\'s\ m |
|
|||||
|
Thx Christoph, Although printf is a much better function for my script, you don't answer at all to my problem. What I need is a way to make the script work in the following situation: Code:
~# cat /usr/local/bin/squote [[ -z "$@" ]] && printf "No input\n" || printf "Input: %q\n" "$@" ~# echo "h's m" | squote No input |
![]() |
| Bookmarks |
| Tags |
| arguments, input |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|