The variable should have the last value which was assigned to it in loop.
Here is an example for it.
We have a script named loop_example.ksh in which variable a have many values but if you will print it's value outside from loop it will show the last one as Sunday in the above example.
I am a newbie to awk and c programming, however am not a unix newbie. However, I do need help with a kshell script I am writing. It is almost complete, the last step is killing me. Any help would be greatly appreciated. What I am trying to do is cat a text file that has usernames. Then, using... (2 Replies)
Hi,
I have a text file with data in that I wish to extract, assign to a variable and process through a loop.
Kind of the process that I am after:
1: Grep the text file for the values.
Currently using:
cat /root/test.txt | grep TESTING= | awk -F"=" '{ a = $2 } {print a}' | sort -u
... (0 Replies)
Hi all
I run my program prog.c in the following way :
$ ./prog 1 > output.txt where 1 is a user defined initial value used by the program.
But now I want to run it for many a thousand initial values, 1-1000, and store all the outputs in different files.
Like
$ ./prog 1... (1 Reply)
Hello
I am having issues with a script I'm working on developing on a Solaris machine.
The script is intended to find out how many times a particular user (by given userid) has logged into the local system for more than one hour today.
Here is my while loop:
last $user | grep -v 'sshd'... (7 Replies)
Hello Everyone,
I'm still trying to grasp many concepts in .ksh scripting, one of them being variables inside loops. My problem is the following:
* I'm trying to set a variable inside a while read loop to reuse it outside of said loop. My lines are the following :... (13 Replies)
Hello,
I'm having trouble with formatting some text via the terminal. I can get it perfectly formatted, but when I try and copy paste the text from the output file it loses it's formatting. Very frustrating!
Basically I have 7 files (data data2 data3 data4 data5 data6 data7) containing a... (13 Replies)
Simple enough problem I think, I just can't seem to get it right.
The below doesn't work as intended, it's just a function defined in a much larger script:
CheckValues() {
for field in \
Group_ID \
Group_Title \
Rule_ID \
Rule_Severity \
... (2 Replies)
I have a shell script (.sh) and I want to pass a parameter value to the awk command but I am getting exception, please assist.
diff=$1$2.diff
id=$2 new=new_$diff
echo "My id is $1"
echo "I want to sync for user account $id"
##awk command I am using is as below
cat $diff | awk... (2 Replies)
I want to create a shell script to add a user and modify its comment field mentioned in a file.
1.
File value:-
username comment field value
xyz123 xyztesting
abc123 abctesting
def123 deftesting
2. i am using below loop to create user... (2 Replies)
I have if loop with multiple variable value check in if loop. How can i print only if loop satisfied variable and its value in shell script ? I dont want to check each variable in if loop. That makes my script larger.
if ]
then
echo "Only satisfied variable with value"
... (3 Replies)