reading files using awk


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting reading files using awk
# 1  
Old 01-26-2011
reading files using awk

Hi ,

I have a awk script to read a file using getline, but when its not able to recognize the path of the file. I am working on solaris unix.

Code:
nawk -F'|' '
BEGIN{
 FILE1="/input_files/temp.txt"
}


I have to place my script in the same folder i.e /input_files/ for my script to work.

Code:
nawk -F'|' '
BEGIN{
 FILE1="temp.txt"
 }

Can you please tell me , wht I am doing wrong here.

Thanks in advance
Rashmi.
Moderator's Comments:
Mod Comment
Please use code tags when posting data and code samples!

Last edited by vgersh99; 01-26-2011 at 10:48 AM.. Reason: code tags, please!
# 2  
Old 01-26-2011
  1. why do you need to use 'getline'?
  2. why do you need to hard-wire the pathname to a file?
  3. please post a complete script and the description of what you're after
  4. please post sample input file(s) and the desired output (using code tags).
# 3  
Old 01-26-2011
Hi Rashmi,

you are using -F.

please remove that -F and keep that filename at the end includin path..
it will print the file..

regards
rajesh
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Open Source

Splitting files using awk and reading filename value from input data

I have a process that requires me to read data from huge log files and find the most recent entry on a per-user basis. The number of users may fluctuate wildly month to month, so I can't code for it with names or a set number of variables to capture the data, and the files are large so I don't... (7 Replies)
Discussion started by: rbatte1
7 Replies

2. Shell Programming and Scripting

Reading txt files using the awk

Dear Shell scripters, I have a small code which copy the txt files from some destination to file name OutPutFile. I want to modify this script to introduce several constant. The string it is reading is like ... (2 Replies)
Discussion started by: nrjrasaxena
2 Replies

3. UNIX for Dummies Questions & Answers

Need Help in reading N days files from a Directory & combining the files

Hi All, Request your expertise in tackling one requirement in my project,(i dont have much expertise in Shell Scripting). The requirement is as below, 1) We store the last run date of a process in a file. When the batch run the next time, it should read this file, get the last run date from... (1 Reply)
Discussion started by: dsfreddie
1 Replies

4. Shell Programming and Scripting

Help with reading two input files in awk

Hello, I'm trying to write an awk program that reads two files inputs. example, file 1: 0.00017835 0.000176738 0.00018811 0.000189504 0.000188155 0.000180065 0.000178991 0.000178252 0.000182513 file 2: 1.7871769E-05 1.5139576E-16 1.5140196E-16 1.5139874E-16 1.7827407E-04 ... (5 Replies)
Discussion started by: joseamck
5 Replies

5. Shell Programming and Scripting

reading number of files..one by one in awk script

Hi I have awk script that is reading data from file and printing the result on the monitor....I need to read more than one file .....one by one... and store the result in output file... ---------- Post updated at 06:41 AM ---------- Previous update was at 06:39 AM ---------- please i need... (4 Replies)
Discussion started by: aldreho
4 Replies

6. Shell Programming and Scripting

Reading files using AWK or SED

hi Friends, Please help me to give a try for writing a shell script either with awk or SED for the below requirement. i have file with 3 lines, each of size 3200 chars, wanted to read this file and divide eachline with 200 columns with differensizes for each column value by keeping seperator.... (3 Replies)
Discussion started by: balireddy_77
3 Replies

7. Shell Programming and Scripting

reading from 2 files using awk

hi, Is it possible to read and compare 2 files which have different Field separators at the same time using awk??? file1: 1,dayal,maruti,Z-234,bangalore,KA,........ 2,yash,esteem,Y-007,delhi,DL,........... . . . fill 2: Z-234|Registered|Bangalore Y-007|Registered|Bangalore . . . ... (2 Replies)
Discussion started by: VGR
2 Replies

8. Shell Programming and Scripting

Reading Two files at the same time using awk

Hi All, I am very new to awk script writing. I have two files(file1 and file2) containing some numbers. I want divide the numbers in file1 with those in file 2 line wise. is it possible to simultaneousely read the information from both files and carry put the division. Thanks a lot in... (6 Replies)
Discussion started by: suneeldutt
6 Replies

9. Shell Programming and Scripting

Reading files using grep/sed/awk

After pouring over my LTKS and Unix in a nutshell, I'm stuck! I have a large (BMC Report File) that has breaks on DM (district managers). After a report header, there is a DM header like: DM: DBP AARON ROBERTS At the end of each DM break, there is: ** END OF REPORT ** ... (6 Replies)
Discussion started by: Jodyman
6 Replies

10. Shell Programming and Scripting

awk reading 2 input files but not getting expected value

I'm reading 2 input files but not getting expected value. I should get an alpha value on file_1_data but not getting any. Please help. >cat test6.sh awk ' FILENAME==ARGV { file_1_data=$0; print "----- 1 Line " NR " -----" $1; next } FILENAME==ARGV { file_2_data=$0; print "----- 2... (1 Reply)
Discussion started by: pdtak
1 Replies
Login or Register to Ask a Question