Google Groups Home Help | Sign in
Message from discussion display multiple lines from file
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
Nezhate  
View profile
 More options May 8, 6:17 am
Newsgroups: comp.unix.shell
From: Nezhate <mazouz.nezh...@gmail.com>
Date: Thu, 8 May 2008 03:17:45 -0700 (PDT)
Local: Thurs, May 8 2008 6:17 am
Subject: display multiple lines from file
Hi all,
I'm looking for command that print any number of lines from a given
file.
For example file1.txt contains 100 lines
using the head command I can printout the first n lines from
file1.txt.
using the tail command I can printout the n last lines from file1.txt
How to do for printing out a block of lines, let say from the 50 th
line to 68 th line ?
I used this but it fails

file_name="file1.txt"

if [ -f  $file_name ] ;then
  tail +$1 $3 | head -n$2
fi

Another question:
How to detect the total number of lines from a given file?
knowing this it will help me to use a for loop to echo all lines that
I want to print.
cheers


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2008 Google