10 More Discussions You Might Find Interesting
1. UNIX for Beginners Questions & Answers
Cope sample1: test.sh
i=0
echo " Outside loop i = $i "
while
do
i=$(( $i + 1))
echo "Inside loop i = $i "
done
echo " Out of loop i is : $i "
When run output :
Outside loop i = 0
Inside loop i = 1
Inside loop i = 2
Inside loop i = 3
Inside loop i = 4
Inside loop i = 5
Inside... (8 Replies)
Discussion started by: Adarshreddy01
8 Replies
2. UNIX for Beginners Questions & Answers
In the else of the main if condition .
else
set lnk = $(readlink -f <path> | cut -d '/' -f7)
echo "$lnk"
if ]
When I run the above on command line , the execution seems to be fine and I get the desired output. But when I try to assign it to a variable within a loop... (12 Replies)
Discussion started by: sankasu
12 Replies
3. Shell Programming and Scripting
In the below for loop, I extract a variable $d which is an id that will change each time. The bash executes the problem that I am having is that p (after the done) is the path with the extracted $d. However, I can not use it in subsequent loops as it is not reconized. I have been trying to change... (3 Replies)
Discussion started by: cmccabe
3 Replies
4. Shell Programming and Scripting
I am not clear why the cnt variable is not increased in the script below:
#!/bin/bash
INPF=${1:-a.txt};
KWDS=${2:-lst}
cnt=0;
grep -v '^#' $KWDS | while read kwd;
do
grep -q $kwd $INPF;
if ; then
echo Found;
((cnt=cnt+1));
fi... (5 Replies)
Discussion started by: migurus
5 Replies
5. Shell Programming and Scripting
I am fairly new to bash and am not sure how to resolve this:
I have a series of geographical long/lat points eg. 50/-30 listed on separate lines in a file called junk2. I have input these into an array and am then using that array in a for loop. Towards the end of the loop I create a file called... (4 Replies)
Discussion started by: lily-anne
4 Replies
6. Programming
Hello,
I'm trying to read the variable "pause" from a for loop without luck. The function is dependant on the outcome of the test within the loop. If i run this, pause is always 0 within the function. Any ideas?
Thanks.
pause=0
users=1
(for (( ; ; ))
do
speed=`cat speed.log`
... (7 Replies)
Discussion started by: shadyuk
7 Replies
7. UNIX for Dummies Questions & Answers
Hi all! I think someone might be able to solve my problem pretty easily.
I am trying to run a bash loop with 3 variables. I know how to do:
for var1 in `cat list1`; do for var2 in `cat list2`; do for var3 in `cat list3`; command var1 var2 > var3; done; done; done
However, this will run all... (4 Replies)
Discussion started by: torchij
4 Replies
8. Shell Programming and Scripting
Hi,
I have a loop running until a variable L that is read previously in the full script. I'd like to grep some information in an input file at a line that contains the value of the loop parameter $i.
I've tried to use grep, but the problem is nothing is written in the FILE files. It seems grep... (5 Replies)
Discussion started by: DMini
5 Replies
9. Shell Programming and Scripting
Over time i have developed a library of useful (ksh) functions which i use in most of my scripts. I use the ksh's FPATH variable to locate all these functions and use a standard environment-setting-function to always have the same environment in all my scripts.
Here is how i begin scripts:
... (3 Replies)
Discussion started by: bakunin
3 Replies
10. Shell Programming and Scripting
hi
i was trying to optimize one script and i came across this problem .. i am putting some pseudo code here
$ >cat a.sh
ls | while read I
do
i=$(($i + 1))
done
echo "total no of files : "
$ >ksh a.sh
total no of files :
$ >bash a.sh
total no of files :
why is... (1 Reply)
Discussion started by: zedex
1 Replies