I am currently tasked with some reporting on various Unix based OSes. I have a script deployed that runs and grabs the information I am looking for, and has a bit of logic to output the desired result into a text file.
Example of my text file:
So, the script that runs basically pulls info from a system, parses it to my desired output, then echoes it to a text file where I can later read it and report or take action on it. My idea was to use a while loop to read these values, then build in if then statements to do a task.
example script:
I have tried numerous ways of doing this, and I honestly hardly ever use while loops so I know there are other ways to do this. Perhaps even better ways, but now that I cannot get it work I am pretty much forcing myself to learn why it is not working.
In my script I would take actions, but the echoes are there as place holders for other commands I may run, as I am in the testing phase.
I am currently tasked with some reporting on various Unix based OSes. I have a script deployed that runs and grabs the information I am looking for, and has a bit of logic to output the desired result into a text file.
Example of my text file:
So, the script that runs basically pulls info from a system, parses it to my desired output, then echoes it to a text file where I can later read it and report or take action on it. My idea was to use a while loop to read these values, then build in if then statements to do a task.
example script:
I have tried numerous ways of doing this, and I honestly hardly ever use while loops so I know there are other ways to do this. Perhaps even better ways, but now that I cannot get it work I am pretty much forcing myself to learn why it is not working.
In my script I would take actions, but the echoes are there as place holders for other commands I may run, as I am in the testing phase.
Thanks,
ZB
In your loop you have a variable named line; you do not define the variables multiUsers and availableDiskSpace. So, your if statements will never match what you're looking for.
Hi,
I want to replace a chain of if-else statement in an old AWK file with values from Db2 table or CSV file. The part of code is below...
if (start_new_rec=="true"){
exclude_user="false";
user=toupper($6);
match(user, "XXXXX.");
if (RSTART ==2 ) {
... (9 Replies)
I have a file containing multiple values, some of them are pipe separated which are to be read as separate values and some of them are single value all are these need to store in variables.
I need to read this file which is an input to my script
Config.txt
file name, first path, second... (7 Replies)
I am trying to read a input file which has two columns separated by space
Input file
server1 server2
server3 server4
server5 server6
When i execute the below while code it reads line by line and a and b variables are able to successfully fetch the values
while read a b
do
echo "$a"
echo... (5 Replies)
Hi,
I have a variable which stores file names as a result of find command. I need to delete all these files one by one, i.e. by a loop. Can anyone tell me how can it be done?
The variable f2d has the file names like these
abc.txt
bcd.txt
fff.txt
gef.txt
Now I have used a loop as... (12 Replies)
Hello All,
Maybe I'm Missing something here but I have NOOO idea what the heck is going on with this....?
I have a Variable that contains a PATTERN of what I'm considering "Illegal Characters". So what I'm doing is looping
through a string containing some of these "Illegal Characters". Now... (5 Replies)
hi,
this is my script #!/bin/ksh
cat temp_file.dat | while read line
do
read test
if ]; then
break
else echo "ERROR"
fi
done
when i execute this code , the script does wait for the user input . it directly prints "ERROR" and terminates after the no. of times as there... (3 Replies)
Hi,
I have a text file with multiple lines, each having data in the below format <DOB>,<ADDRESS>
I have to write a script which reads each line in the text file in loop, assign the values to these variables and do some further processing in it.
Using the following code prints the values... (12 Replies)
Hi,
I have a text file with multiple lines, each having data in the below format
<DOB>,<ADDRESS>
I have to write a script which reads each line in the text file in loop, assign the values to these variables and do some further processing in it.
Using the following code prints the... (1 Reply)
I have read another post about this issue and am wondering how to adapt it
to my own, much simpler, issue.
I have a file of user IDs like so:
333333
321321
546465
...etc
I need to take each number and use it to print records wherein the 5th
field matches the user ID pulled from the... (2 Replies)