Sponsored Content
Full Discussion: file reading in unix
Top Forums Shell Programming and Scripting file reading in unix Post 89699 by pradeepthanraj on Tuesday 15th of November 2005 07:48:29 AM
Old 11-15-2005
file reading in unix

Hi ,
I need to read line by line from a file. Can u please tell me the most efficient way to do it. SInce i will be reading more than 1000 files in my program. i am trying the following options :
1. nawk option
nawk'{
print $0
}'files.temp

2.
filecount=`cat files.temp | wc -l`
i=1
while [ $i -le $filecount ]
do
filename=`cat files.temp | head -$i | tail -1`
#echo $filename
done

can u please tell me the best way to do this.
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Reading Particular Line From A File in Unix

Can any u pls tell me :- I want to read a particular line from a file, say line no. 10. This can be done by using awk..but that method I think, is inefficient. Is there any direct command for this? Thanks (2 Replies)
Discussion started by: yeheyaansari
2 Replies

2. UNIX for Advanced & Expert Users

Reading lines within a Unix file.

I have a file that has a list of numbers in it. Each line has a different number. I am trying to create some sort of loop within a script that will pick the numbers up on lines 1 and 2 and then put those figures into the script. It then goes through the process then loops back and reads lines 2 and... (5 Replies)
Discussion started by: mariner
5 Replies

3. Filesystems, Disks and Memory

reading unix file system from windows

I found a more appropriate section to post my question. Thanks! (0 Replies)
Discussion started by: cneill
0 Replies

4. UNIX for Dummies Questions & Answers

UNIX script for reading a file and creating another file

Hi, I am a beginner in scripting...I have to do a script where I have to read a file which has list of job names, line by line and for every line execute a dsjob command to find the log details of the job and extract only the start time of the job, if it is greater than jan 01 2008 and create... (1 Reply)
Discussion started by: Vijay81
1 Replies

5. Shell Programming and Scripting

UNIX File handling -Issue in reading a file

I have been doing automation of daily check activity for a server, i have been using sqls to retrive the data and while loop for reading the data from the file for several activities. BUT i got a show stopper the below one.. where the data is getting store in $temp_file, but not being read by while... (1 Reply)
Discussion started by: KuldeepSinghTCS
1 Replies

6. Shell Programming and Scripting

UNIX file reading

i have a directory that has n files starting with ABC_00x.txt and ABC_00x.txt where x is the integer number. i want to read the contents of each file and write it into a log file. can somebody help me in writing the shell script in unix (3 Replies)
Discussion started by: vkca
3 Replies

7. Shell Programming and Scripting

Reading UNIX commands from file and redirecting output to a file

Hi All I have written the following script: #!/bin/ksh while read cmdline do echo `$cmdline` pid="$cmdline" done<commands.txt =========== commands.txt contains: ps -ef | grep abc | grep xyz |awk '{print $2}; My objective is to store the o/p of the command in a variable and do... (8 Replies)
Discussion started by: rahulparo
8 Replies

8. Shell Programming and Scripting

How to ignore single or multiple lines between /* and */ while reading from a file in unix?

I have a file proc.txt: if @debug = 1 then message 'Start Processing ', @procname, dateformat(now(*), 'hh:mm:ss'), @julian type info to client; end if; /* execute immediate with quotes 'insert into sys_suppdata (property, value, key_name) location ''' || @supp_server || '.' ||... (5 Replies)
Discussion started by: kidncute
5 Replies

9. Shell Programming and Scripting

Reading input from web into UNIX file

Hi, Could someone let me know how to read input from a web page into a unix file. I am writing my script in bash shell in Solaris version. Thanks in advance, ayarlaga. (7 Replies)
Discussion started by: ayarlaga
7 Replies

10. UNIX for Dummies Questions & Answers

UNIX File reading question

Is there a script that will automatically access/count the words in each individual file for a program? (Sorry, I'm trying to help my girlfriend who's in computer science out, I know nothing about this. We're having trouble wording this question.) (1 Reply)
Discussion started by: Triple M
1 Replies
DBAMSG(1)						      General Commands Manual							 DBAMSG(1)

NAME
dbamsg - Work with encoded meteorological data SYNOPSIS
dbamsg [command] [options] [args...] DESCRIPTION
Examine, dump and convert files containing meteorological data. It supports observations encoded in BUFR, CREX and AOF formats. dbamsg always requires a non-switch argument, that indicates what is the operation that should be performed: help Print a help summary. help manpage Print this manpage. scan [options] [filter] filename [filename [...]] Summarise the contents of a file with meteorological data. dump [options] [filter] filename [filename [...]] Dump the contents of a file with meteorological data. cat [options] [filter] filename [filename [...]] Dump the raw data of a file with meteorological data. convert [options] [filter] filename [filename [...]] Convert meteorological data between different formats. compare [options] filename1 [filename2] Compare two files with meteorological data. fixaof [options] filename [filename1 [...]]] Recomputes the start and end of observation period in the headers of the given AOF files. makebufr [options] filename [filename1 [...]]] Read a simple description of a BUFR file and output the BUFR file.. Read a simple description of a BUFR file and output the BUFR file. This only works for simple BUFR messages without attributes encoded with data present bitmaps. bisect [options] --test=testscript filename Bisect filename and output the minimum subsequence found for which testscript fails.. Run testscript passing parts of filename on its stdin and checking the return code. Then divide the input in half and try on each half. Keep going until testscript does not fail in any portion of the file. Output to stdout the smallest portion for which testscript fails. This is useful to isolate the few messages in a file that cause problems. head [options] [filter] filename [filename [...]] Dump the contents of the header of a file with meteorological data. OPTIONS
dbamsg follows the usual GNU command line syntax, with long options starting with two dashes (`-'). Options used to filter messages --category=num match messages with the given data category --subcategory=num match BUFR messages with the given data subcategory --check-digit=num match CREX messages with check digit (if 1) or without check digit (if 0) --unparsable match only messages that cannot be parsed --parsable match only messages that can be parsed --index=expr match messages with the index in the given range (ex.: 1-5,9,22-30) Option for command scan -?, --help print an help message --verbose verbose output -t type, --type=type format of the input data ('bufr', 'crex', 'aof') Option for command dump -?, --help print an help message --verbose verbose output -t type, --type=type format of the unput data ('bufr', 'crex', 'aof') --interpreted dump the message as understood by the importer --precise import messages using precise contexts instead of standard ones --text dump as text that can be processed by dbamsg makebufr --csv dump in machine readable CSV format --dds dump structure of data description section --structured structured dump of the message contents Option for command cat -?, --help print an help message --verbose verbose output -t type, --type=type format of the input data ('bufr', 'crex', 'aof') Option for command convert -?, --help print an help message --verbose verbose output -t type, --type=type format of the input data ('bufr', 'crex', 'aof', 'csv') -d type, --dest=type format of the data in output ('bufr', 'crex', 'aof') --template=name template of the data in output (autoselect if not specified, 'list' gives a list) -r rep_memo, --report=rep_memo force output data to be of this type of report --precise import messages using precise contexts instead of standard ones --recompute-categories recompute data categories and subcategories according to message contents Option for command compare -?, --help print an help message --verbose verbose output -t type, --type1=type format of the first file to compare ('bufr', 'crex', 'aof') -d type, --type2=type format of the second file to compare ('bufr', 'crex', 'aof') Option for command fixaof -?, --help print an help message --verbose verbose output Option for command makebufr -?, --help print an help message --verbose verbose output Option for command bisect -?, --help print an help message --verbose verbose output --test=cmd command to run to test a message group -t type, --type=type format of the input data ('bufr', 'crex', 'aof') Option for command head -?, --help print an help message --verbose verbose output -t type, --type=type format of the input data ('bufr', 'crex', 'aof') EXAMPLES
Here are some example invocations of dbamsg: # Convert an AOF message to BUFR dbamsg convert file.aof > file.bufr # Convert a BUFR message to CREX dbamsg convert file.bufr -d crex > file.crex # Convert BUFR messages to CREX, but skip all those not in january 2010 dbamsg convert year=2010 month=1 file.bufr -d crex > file.crex # Dump the content of a message, as they are in the message dbamsg dump file.bufr # Dump the content of a message, interpreted as physical quantities dbamsg dump --interpreted file.bufr TEMPLATE NAMES
This is a list of possible template names for the --template switch: acars ACARS (autodetect) acars-ecmwf ACARS ECMWF (4.145) acars-wmo ACARS WMO airep AIREP (autodetect) airep-ecmwf AIREP ECMWF (4.142) amdar AMDAR (autodetect) amdar-ecmwf AMDAR ECMWF (4.144) amdar-wmo AMDAR WMO buoy Buoy (1.21) generic Generic (255.0) metar Metar (0.140) pilot Pilot (2.91) pollution Pollution (8.171) ship Synop ship (autodetect) ship-abbr Synop ship (abbreviated) (1.9) ship-auto Synop ship (auto) (1.13) ship-plain Synop ship (normal) (1.11) ship-reduced Synop ship (reduced) (1.19) synop Synop (autodetect) synop-ecmwf Synop ECMWF (autodetect) (0.1) synop-ecmwf-auto Synop ECMWF land auto (0.3) synop-ecmwf-land Synop ECMWF land (0.1) synop-ecmwf-land-high Synop ECMWF land high level station (0.1) synop-wmo Synop WMO (0.1) temp Temp (autodetect) temp-ecmwf Temp ECMWF (autodetect) temp-ecmwf-land Temp ECMWF land (2.101) temp-ecmwf-ship Temp ECMWF ship (2.102) temp-ship Temp ship (autodetect) temp-wmo Temp WMO (2.101) wmo WMO style templates (autodetect) --template=list will also print the list. AUTHOR
dbamsg has been written by Enrico Zini <enrico@enricozini.com> for ARPA Emilia Romagna, Servizio Idrometeorologico. may 16, 2012 DBAMSG(1)
All times are GMT -4. The time now is 11:06 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy