Re: how can a executing bash script be paused?
- From: Lao Ming <laomingliu@xxxxxxxxx>
- Date: Thu, 18 Dec 2008 14:53:08 -0800 (PST)
On Dec 17, 9:25 pm, Barry Margolin <bar...@xxxxxxxxxxxx> wrote:
In article
<b7812cb6-087e-48c0-8dda-e405433be...@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>,
Lao Ming <laoming...@xxxxxxxxx> wrote:
Is there something unusual about pausing a bash script?
I admit that I haven't done any interactive input since I started
using bash. I want to use 'read' from stdin in order to
slow down a loop when doing:
bash -x script
I tried:
while [ condition ] ; do
processing ...
printf "%s" "Pause: "
read mypause
done
Thanks.
but it doesn't work.
It looks like it should work. Could you be more specific than "doesn't
work"?
Well, this is the script that I am trying to debug. It's a small
script
and does only one thing. It collects the first character of each
filename
(excluding dot files) and places the char into an array (if it doesn't
exist
in the array already). The script does not produce output as it is
right now.
#! /bin/bash -f
check_filename()
{
filename="${FILE##*/}"
if [ "${filename:0:1}" = "." ] ; then
FLAG="true"
else
if [ "$INDEX" != "$PREVIOUS_INDEX" ] ; then
INDEX_ARRAY[$I]=$( echo "${filename:0:1}" |tr '[a-z]' '[A-
Z]' )
(( I++ ))
fi
fi
export INDEX_ARRAY
}
declare -a INDEX_ARRAY
PREVIOUS_INDEX=""
INDEX="0"
I=0
find . -type f -name "[0-z]*" |sort -f |
{
while IFS= read -r FILE ; do
FLAG="false"
INCOMPLETE=$( echo "$FILE" |sed 's/^.\///' ) # remove ^"./"
SLASH=$( echo "$INCOMPLETE" |grep '/' )
if [ "$SLASH" != "" ] ; then
dirspec="${INCOMPLETE%/*}"
#else
# check_filename
# [ "$FLAG" = "true" ] && continue
#fi
#if [ "$dirspec" != "" ] ; then
dirname="${dirspec##*/}"
if [ "$dirname" != "" ] ; then
[ "${dirname:0:1}" = "." ] && continue
else
check_filename
[ "$FLAG" = "true" ] && continue
fi
else
check_filename # new
[ "$FLAG" = "true" ] && continue # new
#filename="${FILE##*/}"
#[ "${filename:0:1}" = "." ] && continue
fi
PREVIOUS_INDEX="$INDEX"
done
echo "${INDEX_ARRAY[@]}"
}
.
- Follow-Ups:
- Re: how can a executing bash script be paused?
- From: Barry Margolin
- Re: how can a executing bash script be paused?
- References:
- how can a executing bash script be paused?
- From: Lao Ming
- Re: how can a executing bash script be paused?
- From: Barry Margolin
- how can a executing bash script be paused?
- Prev by Date: Re: 2 stdout destinations
- Next by Date: bash initialization files
- Previous by thread: Re: how can a executing bash script be paused?
- Next by thread: Re: how can a executing bash script be paused?
- Index(es):
Relevant Pages
|