10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
I'm taking a unix class and need to countdown to 0 from whatever number the user inputs. I know how to do this with a while or until loop but using the for loop is throwing me off....
I know I can use an if-then statement in my for loop but can I include a while loop in my for loop? (3 Replies)
Discussion started by: xxhieixx
3 Replies
2. AIX
Hi,
I am having a file like,
#cat file
Jun 19 13:08
Jun 19 13:08
Jun 19 13:08
Jun 19 13:14
when I run the below comamnd locally it will work fine,
IFS=$'\n'; for i in $(cat file) ;do echo "HI $i" ; done
And the output is,
HI Jun 19 13:08
HI Jun 19 13:08
HI Jun 19 13:08
HI... (1 Reply)
Discussion started by: sumanthupar
1 Replies
3. Shell Programming and Scripting
Hi All,
Below is the very simple code snippet but it si giving me syntax error
#!/bin/bash
#To ensure If JMS directory exists or not
ServerName=$(hostname)
#To ensure If JMS directory exists or not
echo $ServerName
if ;
then
echo "Inside First If"
if ;
then
echo 'JMS... (4 Replies)
Discussion started by: sharsour
4 Replies
4. Shell Programming and Scripting
I'm having problems with this example:
#!/bin/bash
for i in server1 server2 server3
do
ssh $i <<EOF >> logfile.txt
dat1=`date '+%m/%d/%y'`
hst=`hostname`
df -Ph | awk -v OFS=',' -v dat="$dat1,$hst" ' {print dat,$1,$6,$3,$4 } '
exit
EOF
done
I'm... (1 Reply)
Discussion started by: kuliksco
1 Replies
5. Shell Programming and Scripting
Hello,
I'm trying to write (my own primitive) traceroute command that would write out all IPs that packets are hoping through. :)
So I've put the ping command inside a for loop
#!/bin/bash
domain=${1-www.google.com}; #If no argument, then do www.google.com.
for ((i=1; i<=30; i++)) #... (9 Replies)
Discussion started by: courteous
9 Replies
6. 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
7. Shell Programming and Scripting
Hi,
I am using su within a for loop. As you might expect, it prompts for password during each loop execution. Here is my piece of code:
for i in $LIST
do
if
then
DATABASE=`echo $i | awk -F "|" '{ print $1 }'`
USER_ID=`echo $i | awk -F "|" '{ print $2 }'`
su - apstage -c... (1 Reply)
Discussion started by: sugan
1 Replies
8. 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
9. Shell Programming and Scripting
Hi Gurus
I have a file called /tmp/CMDB which looks like this
serial: 0623AN1208
hostname: server1
model: x4100
assetID: 1234
I am writing a for loop that will go through this file line by line creating a variable of itself. Using the first iteration of the loop (i.e. the first line) as... (6 Replies)
Discussion started by: hcclnoodles
6 Replies
10. Shell Programming and Scripting
If I have 3 variables and I want to check if any of these is null. If one of them is null then it should be assigned a value of 0.I have the following code below.
The output should be 0 is A, 11 is B, 33 is C
$a=
$b=11
$c=33
$echo $a $b $c
$11 33
for i in "${a}" "${b}" "${c}";
do
... (2 Replies)
Discussion started by: thana
2 Replies