11-12-2008
Storing information in arrays....
Hello,
I am writing a shell script to do the following. It greps information from the messages log and then I use the cut command to isolate the field I need (the username) and output the information to a text file.
I now have to do the following. Count how many times each user logged in. So if the name "Mike" appears five times in the text file my script has to say Mike logged in five times.
It was suggested to me that I use awk to store the information from the text file in an array and process the information.
Though I am familiar with program design and concepts, I am rather new to shell scripting and awk and would ask the forum to provide me with some concrete code to help me understand what needs to be done.
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi Everyone,
I have a code which requires to be stored in different variables and I am achiving it like this.
HOST=`echo $RMP | cut -f2 -d:`
NAME=`echo $RMP | cut -f3 -d:`
DIR=`echo $RMP | cut -f4 -d:`
TYPE=`echo $RMP | cut -f5 -d:`
Is there any other way of storing value... (2 Replies)
Discussion started by: gehlnar
2 Replies
2. Web Development
PHP question...
I have an SQL query that's pulled back user IDs as a set of columns. Rather than IDs, I want to use their names.
So I have an array of columns $col with values 1,7,3,12 etc and I've got an array $person with values "Fred", "Bert", "Tom" etc
So what I want to do is display the... (3 Replies)
Discussion started by: JerryHone
3 Replies
3. Shell Programming and Scripting
Friends,
I have to execute a command and store its contents into an array using shell. this is what i have tried
#!/bin/bash
disk_names = ($(`iostat -xtc | egrep -v "device|nfs" | awk '{print $1}'| tr '\n' ' ' `))
But its throwing an error message as
./test-script
./test-script:... (6 Replies)
Discussion started by: achak01
6 Replies
4. Shell Programming and Scripting
Hey guys, i am having a problem in storing new data into a text file.
The database in in a text file and it displays information like this :
Name : Price : Quantity
Persia : 80 : 30
Now , i have written the code to check if the book already exist in the Databse.
Number=
echo -n... (3 Replies)
Discussion started by: gregarion
3 Replies
5. Shell Programming and Scripting
Hello,
for an automated telnet login script I need to store a password on the server. Is there a possibility to store the password in an encrypted form and decrypt it every time the login is performed? Are there any ideas
Love, Sally (5 Replies)
Discussion started by: Sally[-_-]
5 Replies
6. Shell Programming and Scripting
I am reading a number of files but then I want to put the ranges
xmin xmax ymin ymax
as arrays for each file.
Any idea how I can do this???
set j = 1
echo "Welcome $i times"
while ( $j <= $i )
echo "$j"
set fname = $fin-bst-misf.xy
echo " "$fname
... (0 Replies)
Discussion started by: kristinu
0 Replies
7. Shell Programming and Scripting
I have the following csh script which lets the use pass the following as an argument
-legend=tag1/tag2/tag3/tag4/tag5/tag6/tag7
We pass a number of tags separated by '/'. I want to save the legend tags in an array and have done as below. How can I improve on this as things are getting quite... (3 Replies)
Discussion started by: kristinu
3 Replies
8. Programming
hi
I need a little help writing this small perl script. I'm trying to extract the values from each line in a file and find the average for example
cat school
Highschool 100, 123, 135
Middleschool 41, 67, 54
Elementary 76, 315, 384
./average.pl
highschool: 119.3
middleschool: 54... (2 Replies)
Discussion started by: gengar
2 Replies
9. Programming
if i declare both but don't input any variables what values will the int array and file pointer array have on default, and if i want to reset any of the elements of both arrays to default, should i just set it to 0 or NULL or what? (1 Reply)
Discussion started by: omega666
1 Replies
10. UNIX for Dummies Questions & Answers
i'm trying to figure out how to store strings into an array, can someone help me figure it out?
i would like to store the following for example:
array = "dog"
array = "cat"
the inputs are coming from the command line.
Thanks, (6 Replies)
Discussion started by: l flipboi l
6 Replies