Sponsored Content
Full Discussion: vlad
Top Forums Shell Programming and Scripting vlad Post 302138336 by barbus on Monday 1st of October 2007 06:43:16 AM
Old 10-01-2007
Quote:
Originally Posted by ghostdog74
Code:
v=0
while read  line
do
 v=$((v+1))
 printf "%s) %s\n"  $v  $line 
done < "file"


This is looks like something I can Smilie

I have a question though, the “while read line” statement, how does this get information from the file, is it from this “done < "file"”?.

sorry if am asking silly questions i only been using UNIX for a week now :P

also can i use the grep to achieve this, if say i will be looking for occurrences of the current user who is executing the script?(in this case it should be me, but i can use it for others)

cat xx| grep -n .\*| grep "^1"

or something like that, i cant test it atm, but i think cat pipes file to 'grep -n' which inserts line numbers and pipes it to 'grep '^1' which gets the line 1. odds are this might fail as this is 1st time i am going to use grep Smilie

Last edited by barbus; 10-01-2007 at 08:19 AM..
 
ZGREP(1)						      General Commands Manual							  ZGREP(1)

NAME
zgrep - search possibly compressed files for a regular expression SYNOPSIS
zgrep [ grep_options ] [ -e ] pattern filename... DESCRIPTION
Zgrep invokes grep on compressed or gzipped files. These grep options will cause zgrep to terminate with an error code: (-[drRzZ]|--di*|--exc*|--inc*|--rec*|--nu*). All other options specified are passed directly to grep. If no file is specified, then the standard input is decompressed if necessary and fed to grep. Otherwise the given files are uncompressed if necessary and fed to grep. If the GREP environment variable is set, zgrep uses it as the grep program to be invoked. EXIT CODE
2 - An option that is not supported was specified. AUTHOR
Charles Levert (charles@comm.polymtl.ca) SEE ALSO
grep(1), gzexe(1), gzip(1), zdiff(1), zforce(1), zmore(1), znew(1) ZGREP(1)
All times are GMT -4. The time now is 09:54 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy