On 2008-03-28, Eric Blake wrote:
> Chris F.A. Johnson gmail.com> writes:
>
>>
>>You can find a shell function to replace the external basename
>>command at: <http://cfaj.freeshell.org/shell/scripts/basename-sh>.
>
> Except that your example
miting was entered.
--
Chris F.A. Johnson, webmaster <http://Woodbine-Gerrard.com>
===
Author:
Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
.
On 2008-06-29, Matt Zyzik wrote:
> bug-bash,
> 2. $( want any newlines chopped off. So to remedy this, I do the
> following: "IFS='' read -r -d '' var < file". Firstly, is this safe
> to do, and are there any other ways? Secondly, it appears to be very
> slow compared to $(http://Woodbine-Gerr
On 2008-07-08, Richard Neill wrote:
> Dear All,
>
> When using read, it would be really neat to be able to pre-fill the form
> with a default (or previous) value.
>
> For example, a script which wants you to enter your name, and thinks
> that my name is Richard, but that I might want to correct it.
gt;
> If you want fully sh-compatible behavior, you have to turn off history
> expansion (set +o history).
I find it adequate to set histchars to an empty string.
--
Chris F.A. Johnson, webmaster <http://Woodbine-Gerrard.com>
===
Author:
Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
[[ "$LINE" =~ example-file ]]; then
MATCH=true;
echo "Match-1"
fi
done
if [ "$MATCH" == true ] ;then
echo "Match-2"
fi
}
--
Chris F.A. Johnson, webmaster <http://Woodbine-Gerrard.com>
===
Author:
Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
error near unexpected token `('
> abz,caz and cba work
Do you have an alias named 'cbz'? If so, unalias it before
defining the function.
--
Chris F.A. Johnson, webmaster <http://Woodbine-Gerrard.com>
===
Author:
Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
or i in *.gif?; do mv --verbose $i ${i%\?}; done
That will break if there are pathological filenames.
for i in *.gif?; do
mv -v -- "$i" "${i%\?}"
done
--
Chris F.A. Johnson, webmaster <http://Woodbine-Gerrard.com>
===
Author:
Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
in *
> do
> chg=echo $f |sed 's:(www.somewhere.net)::'
That assigns echo to $chg and tries to execute $f. Use command
substitution.
> mv $f $chg
> done
for f in *
do
chg=$( echo "$f" | sed 's:(www.somewhere.net)::' )
mv "$f" "$chg"
-u nullglob
> # remove first entry
> unset my_array[0]
> echo "Array [EMAIL PROTECTED]"
> shopt -s nullglob
> # remove first entry
> unset my_array[0]
There is no longer any my_array[0] to unset. Try:
unset my_array[1]
> echo
1
do
printf .
done
echo
exec 11<&-
)
....
--
Chris F.A. Johnson, webmaster <http://Woodbine-Gerrard.com>
===
Author:
Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
r--r-- 1 root root 0 Nov 20 12:22 xa
> -rw-r--r-- 1 root root 0 Nov 20 12:22 xA
>
> # ls -l x[A-Z]
> -rw-r--r-- 1 root root 0 Nov 20 12:22 xA
>
> Any ideas?
You are using a locale that conflates upper- and lowercase as
aAbBcC...yYzZ.
Try it with: export LC_ALL=C
t" matches that, and should be changed. Interesting that it works
> with ^^s (for "Tesst" then), but for all "s", of course.
man bash4:
... the ^ and , expansions match and convert only the first
In bash4.0, the terminal is not reset if this is times out:
read -st1
--
Chris F.A. Johnson, webmaster <http://Woodbine-Gerrard.com>
===
Author:
Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
On Mon, 2 Mar 2009, Chet Ramey wrote:
Chris F.A. Johnson wrote:
In bash4.0, the terminal is not reset if this is times out:
read -st1
Thanks for the report. The cleanup functions were not called on timeout.
The attached patch fixes things for me.
Thanks; that works.
--
Chris F.A
CWORD]}*-sh`
)
COMPREPLY=( "${comprep...@]%-sh}" )
}
Aborting...Aborted
--
Chris F.A. Johnson, webmaster <http://woodbine-gerrard.com>
===
Author:
Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
.
--
Chris F.A. Johnson, webmaster <http://woodbine-gerrard.com>
= Do not reply to the From: address; use Reply-To:
Author:
Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
I would like to see read's -d option expanded to accept a string of
characters, any one of which would terminate input. The character
which terminates input should be stored in a variable, e.g.,
$REPLY_END.
--
Chris F.A. Johnson, webmaster <http://woodbine-ger
unset array2[n]
break
;;
esac
n=$(( $n + 1 ))
done
printf "%s\n" "${arra...@]}"
echo
printf "%s\n" "${arra...@]}"
--
Chris F.A. Johnson, webmaster <http://woodbine-gerrard.com>
= Do not reply to the Fro
ot necessary in this example)
for REC in "${arra...@]}"
do
set -- $REC
printf "Field 1: %s Field 2: %s\n" "$1" "$2"
done
--
Chris F.A. Johnson, webmaster <http://woodbine-gerrard.com>
= Do not reply to the From: address; use Reply-To:
Author:
Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
ve already entered on the
command line.
For example, if I type 'gr' and up-arrow, I will get the last grep
command I used. Keep pressing for earlier instances.
--
Chris F.A. Johnson, webmaster <http://woodbine-gerrard.com>
= Do not reply to the From:
e)
If you want to remove trailing spaces as well:
mapfile < <(sed -e 's/^ *//' -e 's/ *$//' file)
Chet, how about an option to mapfile that strips leading and/or
trailing spaces?
Another useful option would be to remove newlines.
--
Chris F.A. Johnson, we
On Fri, 27 Mar 2009, Lennart Schultz wrote:
Chris,
I agree with you to use the right tool at the right time, and mapfile seems
not to be the right tool for my problem, but I will just give you some facts
of my observations:
using a fast tool like egrep just to find a simple string in my
., and the current incantation is just long enough
to be annoying.
Use a function, e.g.:
p()
{
pp=$( type -p "$@" )
}
--
Chris F.A. Johnson, webmaster <http://woodbine-gerrard.com>
= Do not reply to the From: address; use Reply-To:
Aut
On Thu, 2 Apr 2009, Mike Coleman wrote:
On Thu, Apr 2, 2009 at 11:33 AM, Chris F.A. Johnson wrote:
On Thu, 2 Apr 2009, Mike Coleman wrote:
[Oops--I sent that incomplete.]
It would be nice if there was some really brief syntax for
$(type -p somecommand)
I find myself using this all day
nnig with 0 are required to be interpreted as octal
numbers. 08 and 08 ar enot valid octal numbers.
for i in 0{1..9} 10; do printf "%02d\n" "$[i#0}";done
Or:
printf "%02d\n" {1..10}
Or, in bash4.0:
printf "%s\n" {01..10}
--
Chris F.A.
bash array howtos out there if you google
-mike
--
View this message in context:
http://www.nabble.com/how-to-pass-arguments-with-space-inside--tp22978918p22981193.html
Sent from the Gnu - Bash mailing list archive at Nabble.com.
--
Chris F.A. Johnson, webmaster <http://woodbine-gerrard.com>
= Do not reply to the From: address; use Reply-To:
Author:
Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
command in a variable, but the complex cases
always fail!"
http://mywiki.wooledge.org/BashFAQ/005
"How can I use array variables?"
--
Chris F.A. Johnson, webmaster <http://woodbine-gerrard.com>
= Do not reply to the From: address; use Reply-To:
parameters are my two integer arguments,
but I'd like them to be optional. The size of the array is not fixed.
func()
{
local f_array
eval "f_array=( \"\${...@]}\" )"
printf "%s\n" "${f_arr...@]}"
}
a=( qw er ty ui op )
func a
--
Chris F.A
Am I missing something, or are these extended globbing patterns
equivalent to a plain asterisk?
?(pattern-list) Matches zero or one occurrence of the given patterns
*(pattern-list) Matches zero or more occurrences of the given patterns
--
Chris F.A. Johnson, webmaster <h
On Sat, 16 May 2009, Pierre Gaston wrote:
> On Sat, May 16, 2009 at 2:44 AM, Chris F.A. Johnson
> wrote:
> >
> > Am I missing something, or are these extended globbing patterns
> > equivalent to a plain asterisk?
> >
> > ?(pattern-list) Matches zero or
This is nothing new; it happens in all versions of bash:
printf "Enter something: "
read -e whatever
Press a key, then cursor left (or ^A); the cursor moves to the
beginning of the line, over "E" instead of over the character just
entered.
--
Chris F.A. Johnson, web
; > beginning of the line, over "E" instead of over the character just
> > entered.
>
> This isn't a bug; that's where readline thinks the cursor is.
Why would it think that? It's wrong.
> If you want to use a prompt, use `read -p'.
I like
On Thu, 28 May 2009, Pierre Gaston wrote:
> On Thu, May 28, 2009 at 3:52 PM, Chris F.A. Johnson
> wrote:
> > On Thu, 28 May 2009, Chet Ramey wrote:
> >
> >> >
> >> > This is nothing new; it happens in all versions of bash:
> >> >
>
time consumed by pipeline's execution.
times - Display process times.
read - Read a line from the standard input and split it into fields.
readarray - Read lines from a file into an array variable.
readonly - Mark shell variables as unchangeable.
--
Chris F.A. Johnson, webmaster
leading zeroes in a
> single regular expression:
>
> shopt -s extglob
> n=${n##+(0)}
Or, with standard globbing:
${n#"${n%%[!0]*}"}
> b) Use a loop to remove all leading zeroes, one at a time:
>
> while [[ $n = 0* ]]; do n=${n#0}; done
>
not a variable. As the man page says:
Words of the form $'string' are treated specially.
Note "Words". Inside double quotes, $'\n' is not a word.
>
> If this is a feature, not a bug, then is there a better way to include
> newli
'\n\n'Here are the log-files for
> $(date)$'\n\n'Regards,$'\n\n'$SENDER"
>
> then this doesn't work. There are ways around it, such as:
> - building up the string in pieces or
> - EMAIL_BODY=$(echo -
$ printf -v q[2] "%s" "$RANDOM"
bash: printf: `q[2]': not a valid identifier
I know I can work around it with a temporary variable, but it
would be nice if it could be done in a single step.
--
Chris F.A. Johnson &
mapfile callback code is executed in a subshell.
Would it be possible to make it execute in the current shell?
With mapfile -c1, this would make it possible to work on a file without an
explicit loop, making it much faster.
--
Chris F.A. Johnson <h
On Sun, 19 Jul 2009, Chet Ramey wrote:
Chris F.A. Johnson wrote:
mapfile callback code is executed in a subshell.
It's not. It's executed in the same context as an `eval' or a trap
command.
So it is. Great! I wonder what I was doing wrong before.
--
Chr
On Mon, 20 Jul 2009, Pierre Gaston wrote:
On Mon, Jul 20, 2009 at 5:46 AM, Chris F.A. Johnson wrote:
On Sun, 19 Jul 2009, Chet Ramey wrote:
Chris F.A. Johnson wrote:
mapfile callback code is executed in a subshell.
It's not. It's executed in the same context as an `eval&
On Wed, 22 Jul 2009, Marc Herbert wrote:
It seems polling using "read -t 0" is not supported.
It is supported in bash 4.0.
--
Chris F.A. Johnson <http://cfaj.freeshell.org>
===
k" fails on every patch file. What am I doing wrong?
Thanks,
-Alex
--
Chris F.A. Johnson <http://cfaj.freeshell.org>
===
Author:
Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
On Fri, 24 Jul 2009, michael rice wrote:
> Is there a problem with naming a bash script file "script"? I'm using Fedora
> 11.
Most systems already have a command called 'script'. It is not a
good idea to use the names of existing commands for your scri
"which" command is not a good way to see how a command will
be resolved. It is an external command (and at least one version
will not work with bash), and it doesn't know about shell
functions or aliases.
The command to use is 'type'. With the -a option,
What is the algorithm for order of expansion of associative arrays?
Single-letter subscripts are expanded alphabetically, but longer
subscripts are not.
--
Chris F.A. Johnson, webmaster <http://woodbine-gerrard.
e 1: syntax error: unexpected end of file
>
> well, there isn't a missing " AFAICT, and playing around with them has not
> helped. Does anyone have a way out of this?
Take a look at the arguments you are actually using:
printf "%s\n" ${cc[1]}
Use eval:
f
On Wed, 29 Jul 2009, mk27 wrote:
> >Take a look at the arguments you are actually using:
>
> [root~] printf "%s" ${cc[1]}
> bash-c"timels-l"
>
> Again, I can't see the missing "
Try using the code I posted:
printf "%s\n"
ntain '[' and $x to contain 'A'. However, they
are empty. They do pick up the characters if I change delay to
.0001.
--
Chris F.A. Johnson, webmaster <http://woodbine-gerrard.com>
===
Here is my fast patch.
>
> I already fixed it, thanks.
Do you have a patch for it? It's not fixed with the patches posted so far.
--
Chris F.A. Johnson, webmaster <http://woodbine-gerrard.com>
===
this in the past as well...).
>
> Where are you getting the value 'lastmo' from?
>
> If from 'something like date +"%m"', maybe you could strip off the leading
> zero? I.e.:
>
> lastmo=$(echo "$lastmo"|sed -r 's/0+([0-9])/\1/'
On Tue, 1 Sep 2009, ken wrote:
> Doing very simple math in bash fails if a number begins with a zero (0).
Numbers beginning with 0 are base 8 (octal). 08 and 09 are not
valid octal numbers.
--
Chris F.A. Johnson, webmaster <http://woodbine-gerra
items a, b, c, d, e, f, whereas I would
> expect 3 items 'a b', 'c d', 'e f'. It looks like compgen splits the argument
> to -W on $IFS _and_ whitespace. Or am I missing something?
--
Chris F.A. Johnson, webmaster <http://woodbine-gerrard.com>
gt; ~$ samplestring="x y 'z k'"
> ~$ samplearray=( $samplestring )
eval "samplearray=( $samplestring )"
> ~$ echo ${samplearray[2]}
> 'z
--
Chris F.A. Johnson, webmaster <http://woodbine-gerrard.com>
===
Author:
Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
this...
>
> Counter()
> {
> echo $#
> }
> Counter $IDs
> but that just seems stupid
That's a perfectly good way of doing it, but you will want to turn
off filename expansion if there's a chance that the value may
contain wildcards:
set -f
Counter $ID
comments or is there a better
> alternative to cat in this case?
aptitude install $(cut -d ' ' -f1 programs) -y
--
Chris F.A. Johnson, webmaster <http://woodbine-gerrard.com>
===
Author:
Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
;${basePic:4:1}" = '\)' ]
> then
> echo "Got brackets"
> fi
>
> Fix:
> Unsure, I think the bracket parsing should not be treated as
> expression delimiters if they are enclosed in quotes?
> If they are bare, then trea
>
> Bourne shell has no functions at all.
Had. Only before 1984. Since then it has had functions.
The first shell I used, the Bourne shell on AT&T SVR3.2, had
functions.
--
Chris F.A. Johnson, webmaster
nd store the contents of the query in an array
> >
> > SIGS=$(mysql ${COM_LINE} -e"use ${DB}; SELECT sig from ${table} WHERE
> > sig_file='0';")
>
> That is not an array. It's just a string (scalar) variable.
>
> > ## Set IFS = line feed
uires either a loop, or the
> > use of extended globs.
>
> Not true. You can do it via POSIX and without a loop by using an
> intermediate variable:
>
> foo=00081
> bar=${foo%%[!0]*}
> foo=${foo#$bar}}
Or even without an intermediate variable:
foo=${foo#${foo%%[!0]*}
Instead I use "set -e" systematically. It
> works. It is unpredictable but I do not to care: a safety net with a few
> holes is way better than none at all. The very few times I actually want
> to ignore an error I just append " || true" to the corresponding
> co
uts information to the screen, for example (this is much
oversimplified):
{
x=$(( $something * 2 ))
printf "%d\n" "$x"
}
Now, I want to modify the output. I pipe it through a formatting
command:
{
x=$(( $something * 2 ))
printf "%d\n" "$
<(command) thing) and here strings,
> you should be able to do all your reads without subshells.
Or, to be portable, use a here document:
IFS=: read a b <<.
1:2
.
This works with the output of commands, too:
IFS=- read year month day <<.
$(date +%Y-%m-%d)
.
--
Chr
On Mon, 30 Nov 2009, Lhunath (Maarten B.) wrote:
> On 30 Nov 2009, at 15:56, Chris F.A. Johnson wrote:
> >
> > On Mon, 30 Nov 2009, Greg Wooledge wrote:
> >
> >> On Mon, Nov 30, 2009 at 11:46:03AM +0100, Lhunath (Maarten B.) wrote:
> >>> Don't u
ho $1/*$2)" = "x$1"'/*'"$2"
> }
>
>
> Warning: I find neither "noglob" nor "ls" elegant, sorry!
is_file()
{
for f
do
[ -f "$f" ] && return
done
return 1
}
On Fri, 11 Dec 2009, Sven Mascheck wrote:
...
> comp.unix.shell might match well here and could be entertaining -
> IMHO worth to migrate; objections?
This has been discussed more than once in c.u.s; check the
archives.
--
Chris F.A. Johnson, webmaster <http:/
On Fri, 11 Dec 2009, Antonio Macchi wrote:
> is_file()
> {
> [ -f "$1" ] && return
> return 1
> }
>
> is_file /path/to/dir/* || echo empty
>
>
>
> you don't need to check more than the first element
You may need to; it de
> It _would_ make some sense, however, if its counterpart 'global' existed, as
> it could help clarify the intended usage of the variable.
Of the three, local is the only command I use. It says exactly what
it does.
--
Chris F.A. Johnson, webmaster <http://
e Command substitution chapter
> the proper interpretation logic.
>
>
> --- Comment #3 From SpanKY 2009-12-17 10:32:32 [reply] ---
>
> those two examples are not equivalent. your first snippet boils down to:
> echo \'alfa beta\'
>
> this bugzi
pt
name="optimus"
foo () {
if [ "$name" = "optimus" ]
then
gang="good"
echo "Nice behaviour"
return 0
else
gang="bad"
echo "Naughty behaviour"
return 1
fi
}
b
>
> Description:
> bash died while word completion if filename contains a '*' character
>
> Repeat-By:
> touch file\*1
> touch file\*2
> chmod +x file*
> ./file[tab][tab]
No problem here in 3.2, 4.0 or 4.1
--
Chris F.A. Johnson
On Sun, 7 Feb 2010, Mike Stroyan wrote:
> On Sat, Feb 06, 2010 at 05:35:21PM -0800, DennisW wrote:
> > On Feb 6, 5:37 pm, djackn wrote:
> > > Result = myIpExec(${IPaddr1} ${IPaddr2} ${IPaddr3} ${IPaddr4})
> > >
> > > myIpExec is a c program that normally uses scanf to prompt the user
> > > fo
ly gives the full path to the file, so: "${0%/*}"
--
Chris F.A. Johnson <http://cfajohnson.com>
===
Author:
Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
Pr
On Thu, 11 Feb 2010, Eric Blake wrote:
> According to Chris F.A. Johnson on 2/11/2010 4:23 PM:
> > On Fri, 12 Feb 2010, Peng Yu wrote:
> >
> >> $0 gives the file name of the script. I could use several shell
> >> command to get the directory where the script
# output: 2
> a=1; echo foo|{ a=2; }; echo $a # output: 1
>
> Bug or feature?
Standard behaviour; all components of a pipeline are executed in a
subshell.
--
Chris F.A. Johnson <http://cfajohnson.com>
an unquoted $ character consumes until the
> end of the shell substitution, command substitution, or arithmetic
> substitution, and that entire scan becomes part of the current word being
> parsed).
>
> > This confuses me because, intuitively, I feel that the command substitutio
ieved from the $? variable.
>
> Important detail: The local variable is declared and defined in
> the same step with "local VARNAME=$(do something)".
>
> Problem: The $? variable is always 0 after that statement.
The return status is that of the comm
directory
Try using the same spelling in both instances.
--
Chris F.A. Johnson, <http://cfajohnson.com>
Author:
Pro Bash Programming: Scripting the GNU/Linux Shell (2009, Apress)
Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
environmen\<\-
> > -bash: cd: environmen<-: No such file or directory
>
> In such situations I find completion (TAB) really great since it does
> the hard quoting work for you (and does no typo).
That, or up-arrow (or Ctrl-P) to recall previous command.
--
Chri
neric #59-Ubuntu SMP Wed Mar 24
> 07:28:27 UTC 2010 x86_64 GNU/Linux
> Machine Type: x86_64-pc-linux-gnu
>
> Bash Version: 4.0
> Patch Level: 33
> Release Status: release
>
> Description:
> Typing 'declare -A a=b' crashes bash with a segmentation fau
On Fri, 9 Apr 2010, Greg Wooledge wrote:
> On Fri, Apr 09, 2010 at 11:59:20AM -0400, Chris F.A. Johnson wrote:
> > On Fri, 9 Apr 2010, Marc Herbert wrote:
> > > Le 08/04/2010 22:58, Peng Yu a ?crit :
>
> > > > $ mkdir environment\<\-
> > > > $
pmi[:space:]--auto/p');
If you don't quote $content, echo will put it all on one line.
content=$(echo "$content" | sed -n '/mandriva/,/fi;}/p');
content=$(echo "$content" | sed '/^\s*urpmi[:space:]--auto/p');
--
Chris F.A. Johnson, <
racters that cannot be in a file or directory
name: / and NUL.
--
Chris F.A. Johnson, <http://cfajohnson.com>
Author:
Pro Bash Programming: Scripting the GNU/Linux Shell (2009, Apress)
Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
" is
> > often misleading, compare for instance:
> >
> > type pwd
> > which pwd
> >
> > "which" is misleading in many other cases.
>
> Since pwd is a shell command, when /bin/pwd is actually used? In
> shells that don't have buil
nfortunate side effect from 'declare'
being a duplicate of the (non-standard) typeset builtin.
If would be much more useful (and semantically accurate), if it
just did what its name implies, and left the 'local' builtin for
declaring variable local to a f
%s\n" "$i"
done
Or, without a loop:
printf "%s\n" "$@"
> f a 'b c' d e f g
>
>
> $ ./main.sh
> a
> b
> c
> d
> e
> f
> g
>
>
--
Chris F.A. Johnson, <http://cfajohnson.com>
Author:
Pro Bash Programming: Scripting the GNU/Linux Shell (2009, Apress)
Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
600
>
> ### END OF THE SCRIPT ###
>
> It does not work as I expected. The running script was not terminated after
> 5 seconds. So what's wrong here?
$$ refers to the subshell. Try:
trap 'echo killed by SIGALRM; exit 1' ALRM
function wait_kill()
{
sleep
On Wed, 30 Jun 2010, Clark J. Wang wrote:
> On Wed, Jun 30, 2010 at 12:38 PM, Chris F.A. Johnson
> wrote:
>
> > On Wed, 30 Jun 2010, Clark J. Wang wrote:
> >
> > > I have a bash script like this:
> > >
> > > #!/bin/bash
> > >
> > &g
in") shell you use.
>
>
> Then what's the problem with my script in my original mail? Seems like Bash
> does not handle the signal in a real-time way.
The special variable $$ refers to the current process, even if it
has the same numeric value as the parent script.
--
Chris F.A. Johnson, <http://cfajohnson.com>
Author:
Pro Bash Programming: Scripting the GNU/Linux Shell (2009, Apress)
Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
oduction copy.
(The support scripts for this are in the last chapter of my first
book, Shell Scripting Recipes".)
--
Chris F.A. Johnson, <http://cfajohnson.com>
Author:
Pro Bash Programming: Scripting the GNU/Linux Shell (2009, Apress)
Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
"not found"; fi
It prints nothing. Seems like such a basic concept. Sorry, this newbie
needs help on such trivial matters. :-(
When quoted, the right-hand argument is matched as a string, not an
expression.
--
Chris F.A. Johnson, <http://cfajohnson.com>
Author:
s.
A minor loss of "prettiness" is negligible compared to
portability.
It makes it clear that you are no longer doing what I want, a multi-variable
assignment.
It *is* a multi-variable assignment.
But that's my sense of what looks readable in codeYMMV.
On 8/2/2010
write much more code if
I define them all as functions.
This is "much more code":
F(){ find "$@"; }
than:
alias F=find
I don't think functions are better than aliases here. Any idea?
Many reasons why functions are generally better have already been
gi
s a significant
advantage over standard syntax.
[[ ... ]] is not standard, and offers little over the standard
syntax.
--
Chris F.A. Johnson, <http://cfajohnson.com>
Author:
Pro Bash Programming: Scripting the GNU/Linux Shell (2009, Apress)
Shell Scripting Recipes: A Prob
in the filename.
Either separate them with newlines, or (non-POSIX) use an array.
## POSIX
NL='
'
files=${files:+$files$NL}$nextfile
## Array
files+=( "$nextfile" )
--
Chris F.A. Johnson, <http://cfajohnson.com>
Author:
Pro Bash Programming: Scripting the GNU/Linu
ere are
special characters such as space by adding '\' in front them?
This will supply as many files as possible as arguments to stat:
find . -type f -exec stat --printf "%y %n\n" +
--
Chris F.A. Johnson, <http://cfajohnson.com>
Author:
Pro Bash Programming: Sc
On Sun, 26 Sep 2010, Christopher Roy Bratusek wrote:
btw. How can I remove the last arguement ${!#} ?
I tried args=${@:-${!#}} but that won't work.
args=( "$@" )
unset args[$#-1]
set -- "${ar...@]}"
--
Chris F.A. Johnson, <http://cfajohnson.com>
er You get the idea, I hope.
Or you might put it in a script, expecting to be prompted, and lose
files you need. Aliases are not expanded in a script.
--
Chris F.A. Johnson, <http://cfajohnson.com>
Author:
Pro Bash Programming: Scripting the GNU/Linux Shell (2009, Apr
unknown:0: assertion botched
free: start and end chunk sizes differ
Aborting...
Repeat-By: typing cd '\ or ls "\ will reproduce the above bug
Using: GNU bash, version 4.1.7(2)-release (amd64-portbld-freebsd8.1)
does not seem to produce that error.
Nor does 4.0.28(2)-release on
301 - 400 of 434 matches
Mail list logo