Anyone know?: How the 'for'-loop could stop working in interactive bash shell?!
It is happening with my sessions already second time: a 'for'-loop for some reason stop to work as expected.
That means or it is looping without exitting, or it is not loop even once.
Here example of my try when it is not processing even one loop.
You can see, I start new subshell and 'for' works fine, but returning back, the 'for' doesn't work again"
Does anybody know what could be a reason?
I do not think it is related to connection soft (I use PuTTY.)
It is correct, you can't reproduce it!
And I too, can not reproduce it!
I have this situation second time.
First time I have spend couple hours trying to realize what is wrong with my script, untill did not gess to try it in another session, where everything works fine.
Now some how it is happened again. Hopefully some time I could learn from past; so I have realized it shortly.
Now the session is oppened and I could make some test, if anybody would advice to try anything
As I have said, I have no idea how and why that is happening and that is my question, if anybody have any clue about that?!?!
Hello,
this may be a long shot, but maybe You have an alias or something that is active in Your first shell (a login shell perhaps, that read .bash_login?) and the next shell is not a login shell and hence has some other definitions that overrule the first ones?
save output from alias and set from each shell and compare them. It maybe a lot of text but You said You wanted to understand...
use sort and -u on each file to narrow down size and then diff.
Relation to login is not a reason, because a new connection has no problem originally. When that happened I di not know.
I have compared the aliases:
In another session:
Also I have saved result of 'typeset' and 'env'
Later will review (some function I could add, change during mork.)
Location: Saint Paul, MN USA / BSD, CentOS, Debian, OS X, Solaris
Posts: 2,288
Thanks Given: 430
Thanked 480 Times in 395 Posts
Hi.
It might be useful to see how the shell is interpreting everything. Using set -x will show you the commands. This is from a vanilla bash called as sh:
cheers, drl
I have a loop with cases
I am working on Bourne shell
for file in *.${Today}*.csv *.${Today}*.txt\
do
case ${file} in
sun_detail)
do something
;;
sum)
do something
;;
mod)
do something
;;
*)
do something
;; (5 Replies)
Hi
I'm using this script to transcode videos in an Ubuntu 12.04 machine.
#! /bin/bash
MOVDIR="/media/topaz_1/media/transcodes/transcode_mov/"
MOVDESTDIR="/media/topaz_1/media/transcodes/final_mov/"
DONEFILESDIR="/media/topaz_1/media/transcodes/dv_cache/"... (1 Reply)
Hi,
I am trying to run the factorial script but it’s not working.
The code is mentioned below:
------------------------------------------------------------------
/home/gc> cat fact.sh
#!/bin/bash
# using one command line parameter
factorial=1
for (( number = 1; number <= $1 ;... (3 Replies)
I have a strange problem.
I have the following in a cron to find files older than a day.
find /dir1/dir2/ ! -name . -prune -name "s*.txt" -type f -mtime +1 -exec echo {} \; | wc -w
It was working fine for the last few days now it suddenly stopped working. I can clearly see files in the... (5 Replies)
Hi Friends,
I am presently migrating shell scripts writter in KSH to SH.I am stuck at this place and i am not able to find a work around:-
Let the script name is x.sh
Below are some of the codes in it...
export abc=hello
export abc=hi
export abc=how
When i am trying to compile the script ... (6 Replies)
Hi-
Here is the shell script that for some reason is not returning results:
#! /bin/ksh -
avg() {
AVG=0
typeset SUM=0
if
then
echo "You must have at least two numbers"
else
for NUM in "$*"
do
... (2 Replies)
Hi Im running this script, which is supposed to find the max value build some tables and then stop running once all the tables are built. Thing is , it keeps assigning a null value to $h and then $g is null so it keep building tables i.e. testupdateNUL. How can I stop this? Here is what I have:
... (4 Replies)
Q. Write a script that behaves both in interactive and non interactive mode. When no arguments are supplied it picks up each C program from the directory and prints first 10 lines.
It then prompts for deletion of the file.
If user supplies arguments with the script , then it works on those files... (1 Reply)
i have this code for a simple if loop:
#!/bin/bash
array="1 2 3 4 5"
array2="5 6 7 8 9"
if } -gt ${array} ]; then
echo "${array2} is greater than ${array}!!"
fi
the error is
./script8: line 9: [: too many arguments
./script8: line 9: [: too many arguments
./script8: line 9: [:... (10 Replies)
Everything else seems to be working, but this isn't. Is it the "cat..." that is wrong of the condition? Thanks.
cat tc_result.txt | while read LINE
do
if
then
let "files_run += 1";
echo "inside the if loop"
# save current filetype
case $LINE... (5 Replies)