need some help getting started on this script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting need some help getting started on this script
# 1  
Old 10-20-2008
need some help getting started on this script

Hi. I am just getting into scripting. I came into a situation where I need to go through several hundred files on a Linux system and find a couple specific bits of information from within each file. All the files have pretty much identical content except for a view data values on the same two lines in each file. I want to make a script that can go through them all and get each data value so I can manipulate them.

I know this is kind of a broad question, but I am really just trying to figure out where to get started. I am a bit of a Linux and programming novice, so I think this is going to be something difficult. Now I am reading about bash scripting from several different websites, but it seems like I might have to go through a lot of stuff and study for a few weeks before I can even accomplish something. I need to get this done much sooner than that.

Can anyone refer me to a good script site where I can dissect already made similar scripts or maybe a page that talks about file reading and manipulation scripts?

Any other kind of help is appreciated...

EDIT: I mean, what kind of commands would be wise to put in this script? Find? AWK?

Last edited by Dave247; 10-20-2008 at 09:57 PM..
# 2  
Old 10-21-2008
Code:
find /directory/to/files -type f -name 'somename*.log' |\
while read file 
   grep -e 'pattern1' -e 'pattern2' -e 'pattern3' $file
done > outputfile

If you give us the things you are searching for we can help you create the search patterns.
# 3  
Old 10-21-2008
from the "Gosh, you STILL learn things every day" department,

I never realised that you can have more than one search expression for grep, I'm sure I should have done, and should now feel stupid, but thank you anyway for today's lightbulb.
# 4  
Old 10-21-2008
Quote:
Originally Posted by jim mcnamara
Code:
find /directory/to/files -type f -name 'somename*.log' |\
while read file 
   grep -e 'pattern1' -e 'pattern2' -e 'pattern3' $file
done > outputfile

If you give us the things you are searching for we can help you create the search patterns.

hey Jim thanks!

The file has a bunch of text and numbers but I just need to gather a number that is on like the 20th line of the file but the number is also after some text like this:

text file:
text
text
text
text
total numbers of something: 250900
total numbers of another thing: 750325
text
text
text

How do I get my script to go to those numbers? i will likely be putting them into a variable for computation and then so on for each file in the folder until they have all been gone through.
# 5  
Old 10-22-2008
im still having trouble... im trying to learn how to use the sed command
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Inotifywait restart script prevents reboot when started

Hi, maybe someone could help me optimizing this little script. It works so far, but when running, reboot does not work. If kill inotifywait reboot from shell works. I think some optimization is required here. This script starts at the end of the boot process, from an external device and... (3 Replies)
Discussion started by: lowmaster
3 Replies

2. Shell Programming and Scripting

Check whether shell script has started.

How can i ceck as shellscript, if a other shellscript has been started? The other script can bee started by a other user. The task will not run twice (5 Replies)
Discussion started by: Linuxmann
5 Replies

3. UNIX for Dummies Questions & Answers

Show ksh script started on boot

Hi, i need to know, which ksh script are executed on boot (Sun and aix OS). Where can i find it ? (5 Replies)
Discussion started by: nash83
5 Replies

4. Shell Programming and Scripting

Time elapsed since script started

Hi I want to know if there is anyway I can find out how long it has been since I started my script or total time it has been since my script is executing. Idea here is I want to check if my script is taking more than 30minutes to execute I want to kill that process. Thanks in advance. (1 Reply)
Discussion started by: dashing201
1 Replies

5. AIX

How to check a script was started using 'sudo' ?

How can I from within a script, find out if that script was started using 'sudo' and by a valid soduer ? (1 Reply)
Discussion started by: Browser_ice
1 Replies

6. Shell Programming and Scripting

Different time format in script, started in shell or in cron

I try to write a python script, which analyze user logon time with "who" command. When i start script in bash, i get this result: USER=mnadmin tty7 2009-04-18 11:37 (:0) But when i start script in cron, i get result like this: USER=mnadmin tty7 Apr 18 11:37 (:0) I see -... (2 Replies)
Discussion started by: jrush
2 Replies

7. UNIX for Dummies Questions & Answers

getting started

hi world, I am trying to learn how to program in c, I've gotten a few books and have been reading them, one even came with bloodshed dev-c compiler, it is not working, every time I build the hello world program it always comes back saying " G__~1.EXE: installation problem, cannot exec `cpp': No... (1 Reply)
Discussion started by: jsayres
1 Replies

8. Shell Programming and Scripting

How to get rid of message when script kills process it started?

When I run the following script I get the following error message whcih I would like to suppress when the kill is issued: ./kill.sh: line 13: 31854 Killed nc -l -p 12345 Script: #!/bin/bash echo running nc in the background nc -l -p 12345 & PID=$! echo nc pid: $PID ... (1 Reply)
Discussion started by: cmarkle
1 Replies

9. UNIX for Dummies Questions & Answers

Help getting started!!!!

Hi im a 15 year old, interested in beggining things like this...my main inpiration came from this article...How To Become A Hacker according to this my first language shouold be python...but i have ABSOLUTELY NO CLUE about where to dowload/learn it...is there anything else i should do along... (1 Reply)
Discussion started by: SonOfSparta
1 Replies

10. UNIX for Dummies Questions & Answers

Help getting started

Dear all, I just found out that my company is thinking of installing a unix server and is considering either sun or ibm. The thing is that i want to learn these two systems before they take a decision and maybe it will be a big career booster. The problem is that i don't know anything about... (7 Replies)
Discussion started by: patslaiby
7 Replies
Login or Register to Ask a Question