Looking for help with parsing file contents in bash [newbie]


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Looking for help with parsing file contents in bash [newbie]
# 1  
Old 11-13-2011
Looking for help with parsing file contents in bash [newbie]

Hi

I'm just messing around with bash and trying to learn it because I have a course next semester dealing with OS design where we need to know how to use SSH client and either bash or ksh. I've never done shell scripting before.

I just started today and I was wondering how parsing files works. I'm looking at this guide (unstable.blogspot.com/2010/04/simple-bash-script-to-parse-log-file.html *sorry for that but it says i can't post url cuz im new here)but I had a few questions.

unstable.blogspot.com/2010/04/simple-bash-script-to-parse-log-file.html


How do I set the directory so it finds that file? I keep getting "can't open log.txt"

I know its a nooby questiong sorry.
# 2  
Old 11-13-2011
If the file is not in the current directory then you need to provide the entire path...
Code:
cat /full/path/to/your/file/log.txt

HTH
--ahamed
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Bash command to find a file and print contents

I need to find a file and print its contents I am trying but it is not working find -path /opt/app-root/src/.npm/_logs -type f -name "*.log" -print Version $ bash -version GNU bash, version 4.4.12(1)-release (x86_64-pc-msys) (1 Reply)
Discussion started by: SVRao19056
1 Replies

2. Shell Programming and Scripting

Newbie help - parsing through a file

Hello guys, I am a newbie to all of this - I'd like some help with a file I have. It's a ~100mb CSV file with approximately 30 columns. What I'd like to do is to search through the file and REMOVE any lines with a certain case insensitive string in any of the columns: So my file looks... (4 Replies)
Discussion started by: Lokhtar
4 Replies

3. UNIX for Advanced & Expert Users

Parsing a file in bash

Hello All, I have the following input file that i'm trying to parse: 10.0.011.40 hadoop 15526 15524 0 hadoop 15528 15526 0 hadoop 19747 4018 1 10.0.081.227 hadoop 2862 2861 0 hadoop 2864 2862 0 hadoop 12177 14376 1 I'm trying to get this in my output file: 10.0.011.40 15526 15528... (2 Replies)
Discussion started by: ramky79
2 Replies

4. Shell Programming and Scripting

BASH- Hold script until all contents of a file is written

I have to hit a very large database to pull fields of information. I have a script that runs multiple instance of the same query against the data base and writes contents to a file. The script terminates before the file is completely written to confirmed by ps -ef | grep <script name>... (3 Replies)
Discussion started by: popeye
3 Replies

5. Shell Programming and Scripting

parsing a config file using bash

Hi , I have a config _file that has 3 columns (Id Name Value ) with many rows . In my bash script i want to be able to parse the file and do a mapping of any Id value so if i have Id of say brand1 then i can use the name (server5X) and Value (CCCC) and so on ... Id Name ... (2 Replies)
Discussion started by: nano2
2 Replies

6. Shell Programming and Scripting

Most reliable way to store file contents in an array in bash

Hi Guys, I have a file which has numbers in it separated by newlines as follows: 1.113 1.456 0.556 0.021 -0.541 -0.444 I am using the following code to store these in an array in bash: FILE14=data.txt ARRAY14=(`awk '{print}' $FILE14`) (6 Replies)
Discussion started by: npatwardhan
6 Replies

7. Shell Programming and Scripting

Bash copy file contents into an existing file at a specific location

Hi all I need to copy the entire contents of one file into an existing file at a specific location. I know the exact line number where I need to put it. It appears I would use either sed or awk to do this, but I have been unsuccessful so far: File A line 1 line 2 line 3 line 4 ... (6 Replies)
Discussion started by: gshepherd7
6 Replies

8. Shell Programming and Scripting

parsing a file and manipulating the contents

Hi I have a text file as follows BOB 14/14 TOM 94/94 SAM 3/3 CRIS 13/13 TOM 6/6 CRIS 27/27 SAM 2/2 JACK 25/25 CRIS (6 Replies)
Discussion started by: shellignorant
6 Replies

9. Shell Programming and Scripting

Need help in parsing text file contents

Hi, I need some help in extracting the Exception block between the lines 21 Feb 01:18:54:146 ERROR com.orbits.frameworks.integrationframework.ValidationException - Caught exception in validateRequest() (PID=565584) and 21 Feb 01:18:55:149 INFO ... (0 Replies)
Discussion started by: Alecs
0 Replies

10. Shell Programming and Scripting

File contents parsing

Suppose I have a file which has either the contents CALLED on <date & time> RUNNING on <date & time>or CALLED on <date & time> RUNNING on <date & time> SHUTTING_DOWN on <date & time> DOWN on <date & time> I don't care about the <date & time> part... I just need to know if the last line in... (3 Replies)
Discussion started by: orno
3 Replies
Login or Register to Ask a Question