10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
Hi,
I am using a for loop to manipulate files data_1.txt through data_100.txt. The for-loop is set up like this:
for i in {1..100}; do cut -f1 data_$i.txt > output$i.txt
I get the following error message when I run the code:
cannot open `data.txt' for reading: No such file or directory... (4 Replies)
Discussion started by: evelibertine
4 Replies
2. Shell Programming and Scripting
i=0
numberofproducts=${#urls} #gets number of entries in array called "urls"
numberofproductsminusone=`expr $numberofproducts - 1` #-subtract by one
while
do
wget ${urls}
i=$(( $i + 1 ))
sleep 10
done
I'm getting an error
./scrape: line 22: [0: command not found
that... (3 Replies)
Discussion started by: phpchick
3 Replies
3. Shell Programming and Scripting
for (( i=1; i<=3; i++ )); do
for (( j=1; j<=3; j++ )); do
for (( k=1; k<=3; k++ )); do
echo $i$j$k
done
done
done
Will the above code work on a BOURNE shell?
As far as my understanding is, if I am writing the above code in a file..say lol.sh and then running it through the terminal using... (7 Replies)
Discussion started by: navienavnav
7 Replies
4. Shell Programming and Scripting
Hi all
Sorry for the basic question, but i am writing a shell script to get around a slightly flaky binary that ships with one of our servers. This particular utility randomly generates the correct information and could work first time or may work on the 12th or 100th attempt etc !.... (4 Replies)
Discussion started by: rethink
4 Replies
5. Shell Programming and Scripting
I'm trying to understand if it's possible to create a set of variables that are numbered based on another variable (using eval) in a loop, and then call on it before the loop ends.
As an example I've written a script called question (The fist command is to show what is the contents of the... (2 Replies)
Discussion started by: DeCoTwc
2 Replies
6. Shell Programming and Scripting
Hi ,
I am currently using the while loop in bash shell, as follows.
while read line
do
echo $line
done < file.txt
However, i want to use the while loop on file.txt, which will read the file with 4 lines of gap.
Ex- if file.txt is a file of 100 lines, then i want to use the loop such... (3 Replies)
Discussion started by: jitendriya.dash
3 Replies
7. UNIX for Dummies Questions & Answers
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... (14 Replies)
Discussion started by: alex_5161
14 Replies
8. Shell Programming and Scripting
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)
Discussion started by: npatwardhan
10 Replies
9. Shell Programming and Scripting
I have file named script1 as follows:
#!/bin/bash
count="0"
echo "hello"
echo "$count"
while
do
echo "$count"
count=`expr $count + 1`
done
-----------
when I run it, I get
./script1: line 9: syntax error near unexpected token `done'
./script1: line 9: `done'
I... (6 Replies)
Discussion started by: npatwardhan
6 Replies
10. Shell Programming and Scripting
Hi,
I use AIX (ksh) and Linux (bash) servers. I'm trying to do scripts to will run in both ksh and bash, and most of the time it works. But this time I don't get it in bash (I'm more familar in ksh).
The goal of my script if to read a "config file" (like "ini" file), and make various report.... (2 Replies)
Discussion started by: estienne
2 Replies