Sponsored Content
Top Forums Shell Programming and Scripting [Solved] Read a .gz file line by line without using gzcat Post 302459688 by aikhaman on Tuesday 5th of October 2010 07:45:10 AM
Old 10-05-2010
[Solved] Read a .gz file line by line without using gzcat

Hi all
Is there a way to read and process a gzip file line by line similar to a text file without using gzcat..

while processing a text file we will usually use the logic
Code:
exec<sample.txt
while read line
do 
echo $line
done

Is there a similar way to process the gz file in the same manner line by line without using gzcat .Thanks all in advance

Last edited by vbe; 10-05-2010 at 09:40 AM.. Reason: code tags please - the howto is in the forum rules...
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

shell script to read a line in gps receiver log file and append that line to new file

Hi, I have gps receiver log..its giving readings .like below Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. GPSD,R=1 $GPGSV,3,1,11,08,16,328,40,11,36,127,00,28,33,283,39,20,11,165,00*71... (3 Replies)
Discussion started by: gudivada213
3 Replies

2. Shell Programming and Scripting

bash: read file line by line (lines have '\0') - not full line has read???

I am using the while-loop to read a file. The file has lines with null-terminated strings (words, actually.) What I have by that reading - just a first word up to '\0'! I need to have whole string up to 'new line' - (LF, 10#10, 16#A) What I am doing wrong? #make file 'grb' with... (6 Replies)
Discussion started by: alex_5161
6 Replies

3. Shell Programming and Scripting

[Solved] Problem in reading a file line by line till it reaches a white line

So, I want to read line-by-line a text file with unknown number of files.... So: a=1 b=1 while ; do b=`sed -n '$ap' test` a=`expr $a + 1` $here do something with b etc done the problem is that sed does not seem to recognise the $a, even when trying sed -n ' $a p' So, I cannot read... (3 Replies)
Discussion started by: hakermania
3 Replies

4. Shell Programming and Scripting

Read file line by line and process the line to generate another file

Hi, i have file which contains data as below(Only sample shown, it may contain more data similar to the one shown here) i need to read this file line by line and generate an output file like the one below i.e based on N value the number of MSISDNs will vary, if N=1 then the following... (14 Replies)
Discussion started by: aemunathan
14 Replies

5. Shell Programming and Scripting

Shell script to read a text file line by line & process it...

Hi , I am trying to write an shell, which reads a text file (from a location) having a list of numbers of strictly 5 digits only ex: 33144 Now my script will check : 1) that each entry is only 5 digits & numeric only, no alphabets, & its not empty. 2)then it executes a shell script called... (8 Replies)
Discussion started by: new_to_shell
8 Replies

6. Shell Programming and Scripting

how to read the contents of two files line by line and compare the line by line?

Hi All, I'm trying to figure out which are the trusted-ips and which are not using a script file.. I have a file named 'ip-list.txt' which contains some ip addresses and another file named 'trusted-ip-list.txt' which also contains some ip addresses. I want to read a line from... (4 Replies)
Discussion started by: mjavalkar
4 Replies

7. Shell Programming and Scripting

[Solved] Not able to read the next line from a file after doing ssh

Hi, I am trying to write a code, where it reads the jobnames from a file and checks for the logs in the server. If the log is not found in the first server, then it will ssh to the 2nd server and get the details from there. I will need to save the date in a variable. But the problem is that,... (0 Replies)
Discussion started by: ajayakunuri
0 Replies

8. Shell Programming and Scripting

[Solved] While read line and if statement not working

I'm looking for some help in figuring why my little bit of code will not process any entries other then the first one in my list. while read line ;do hostname=${line//\"} a=`ssh user@$hostname uptime;echo $?` if ];then dt=`date` touch... (6 Replies)
Discussion started by: whegra
6 Replies

9. Shell Programming and Scripting

Need a program that read a file line by line and prints out lines 1, 2 & 3 after an empty line...

Hello, I need a program that read a file line by line and prints out lines 1, 2 & 3 after an empty line... An example of entries in the file would be: SRVXPAPI001 ERRO JUN24 07:28:34 1775 REASON= 0000, PROCID= #E506 #1065: TPCIPPR, INDEX= 003F ... (8 Replies)
Discussion started by: Ferocci
8 Replies

10. Shell Programming and Scripting

How to read file line by line and compare subset of 1st line with 2nd?

Hi all, I have a log file say Test.log that gets updated continuously and it has data in pipe separated format. A sample log file would look like: <date1>|<data1>|<url1>|<result1> <date2>|<data2>|<url2>|<result2> <date3>|<data3>|<url3>|<result3> <date4>|<data4>|<url4>|<result4> What I... (3 Replies)
Discussion started by: pat_pramod
3 Replies
MOUNT_PORTAL(8) 					    BSD System Manager's Manual 					   MOUNT_PORTAL(8)

NAME
mount_portal -- mount the portal daemon SYNOPSIS
mount_portal [-o options] /etc/portal.conf mount_point DESCRIPTION
The mount_portal command attaches an instance of the portal daemon to the global filesystem namespace. The conventional mount point is /p. The directory specified by mount_point is converted to an absolute path before use. This command is normally executed by mount(8) at boot time. The options are as follows: -o Options are specified with a -o flag followed by a comma separated string of options. See the mount(8) man page for possible options and their meanings. The portal daemon provides an open service. Objects opened under the portal mount point are dynamically created by the portal daemon accord- ing to rules specified in the named configuration file. Using this mechanism allows descriptors such as sockets to be made available in the filesystem namespace. The portal daemon works by being passed the full pathname of the object being opened. The daemon creates an appropriate descriptor according to the rules in the configuration file, and then passes the descriptor back to the calling process as the result of the open system call. NAMESPACE
By convention, the portal daemon divides the namespace into sub-namespaces, each of which handles objects of a particular type. Currently, four sub-namespaces are implemented: tcp, fs, rfilter and wfilter. The tcp namespace takes a hostname and a port (slash sepa- rated) and creates an open TCP/IP connection. The fs namespace opens the named file, starting back at the root directory. This can be used to provide a controlled escape path from a chrooted environment. The rfilter and wfilter namespaces open a pipe to a process, typically a data-filter such as compression or decompression programs. The rfilter namespace opens a read-only pipe, while the wfilter namespace opens a write-only pipe. See the EXAMPLES section below for more exam- ples. CONFIGURATION FILE
The configuration file contains a list of rules. Each rule takes one line and consists of two or more whitespace separated fields. A hash (``#'') character causes the remainder of a line to be ignored. Blank lines are ignored. The first field is a pathname prefix to match against the requested pathname. If a match is found, the second field tells the daemon what type of object to create. Subsequent fields are passed to the creation function. The rfilter and wfilter namespaces have additional meanings for the remaining fields. The third field specifies a prefix that is to be stripped off of the passed name before passing it on to the pipe program. If the prefix does not match, no stripping is performed. The fourth argument specifies the program to use for the pipe. Any remaining fields are passed to the pipe program. If the string ``%s'' exists within these remaining fields, it will be replaced by the path after stripping is performed. If there is no field after the program name, ``%s'' will be assumed, to maintain similarity with the tcp and fs namespaces. FILES
/p/* EXAMPLES
A tutorial and several examples are provided in /usr/share/examples/mount_portal. The following is an example configuration file. # @(#)portal.conf 5.1 (Berkeley) 7/13/92 tcp/ tcp tcp/ fs/ file fs/ echo/ rfilter echo/ echo %s echo_nostrip/ rfilter nostrip echo %s echo_noslash rfilter echo_noslash echo %s gzcat/ rfilter gzcat/ gzcat %s gzip/ wfilter gzip/ gzip > %s gzip9/ wfilter gzip9/ gzip -9 > %s ftp/ rfilter ftp/ ftp -Vo - %s ftp:// rfilter nostrip ftp -Vo - %s http:// rfilter nostrip ftp -Vo - %s bzcat/ rfilter bzcat/ bzcat %s nroff/ rfilter nroff/ nroff -man %s As is true with many other filesystems, a weird sense of humor is handy. Notice that after the keynames, like nroff/ and bzcat/, we typically use another slash. In reality, the mount_portal process changes direc- tory to /, which makes the subsequent slash unnecessary. However, the extra slash provides a visual hint that we are not operating on an ordinary file. An alternative would be to change the configuration file to something like: nroff% rfilter nroff% nroff -man One might then use less /p/nroff%/usr/share/man/man8/mount_portal.8 SEE ALSO
mount(2), unmount(2), fstab(5), mount(8) HISTORY
The mount_portal utility first appeared in 4.4BSD. The rfilter and wfilter capabilities first appeared in NetBSD 1.5. The portal kernel driver was removed and mount_portal was converted to use puffs(3) in NetBSD 6.0. BUGS
This filesystem may not be NFS-exported. BSD
December 5, 2009 BSD
All times are GMT -4. The time now is 05:12 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy