display lines after a particular line number


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers display lines after a particular line number
# 1  
Old 12-28-2006
display lines after a particular line number

I have a file that has 1k lines and i want to print all the lines after 900th line.

an 2)I want to move files f1 ,f2,f3,f4 to p1,p2,p3,p4

Please give me the commands.

Thanx in adv.
# 2  
Old 12-28-2006
1) sed -n '900,$p' file_name
# 3  
Old 12-29-2006
And for 2)
Code:
$ ls      
f1      f2      f3      f4
$ for file in f[1-4]; do
>   mv $file `echo "$file" | tr 'f' 'p'`
> done
$ ls
p1      p2      p3      p4

Cheers
ZB
# 4  
Old 12-30-2006
900th line means i am storing a value in a variable in x.

i want to execute

sed -n '$x,$p' fname ==========> iam getting syntax error
# 5  
Old 12-30-2006
chk this

Code:
sed -n $x',$p' fname

# 6  
Old 01-03-2007
Code:
awk 'BEGIN{lineno=900} {if( NR >= lineno) { print }}' filename

# 7  
Old 01-03-2007
Quote:
Originally Posted by rajashekar.y
900th line means i am storing a value in a variable in x.

i want to execute

sed -n '$x,$p' fname ==========> iam getting syntax error
Code:
sed -n "$x,$ p" fname

 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How do we display specific row of an output from bottom given line number?

I pass a number to my script. Passing "1" below. ./getfile.sh 1 echo "User entered: $1" ls -ltr *.conf | sed -n '$p' I wish to use ls -ltr i.e list files in ascending order of time the latest showing at the bottom of the output. Number 1 should get me the last row of ls -ltr output i.e... (9 Replies)
Discussion started by: mohtashims
9 Replies

2. Shell Programming and Scripting

How to display the line number of file while searching for a pattern

awk 'BEGIN{IGNORECASE=1} /error|warning|exception/ { ++x } END { print x }' filename The above command returning the number of times the pattern present in the file. But I want the the line number as well. please help me out (6 Replies)
Discussion started by: arukuku
6 Replies

3. UNIX for Advanced & Expert Users

query display number lines or records present in file only numeric value -without filename

Hi all Thanks in advance........... Please help me for this issue............ I have a file it has 11 records . I used the command like .... >$ wc -l file 11 file I'm getting output like 11 file (no.of records along with filename) here my requirement is, I want to display only... (3 Replies)
Discussion started by: ksrivani
3 Replies

4. UNIX Desktop Questions & Answers

How to display only the lines from a file which do not contain a given number

a. How do I display the content of the file containing what Ive merged using a filter which would display only the lines of the file which don't contain number, for example 3 or 6. (3 Replies)
Discussion started by: herberwz
3 Replies

5. Shell Programming and Scripting

Display Specific line number using tail command

Hi , 1)i want to display specific line number using tail command. e.g. display 10 line from end. Please help... 2)Want to display line 10 to 15 (from end)using tail command) (2 Replies)
Discussion started by: vivek1489
2 Replies

6. Shell Programming and Scripting

How to only display lines where a field has the highest number?

Hello Wondering if anybody can advise me how I can sort the below file so it only displays lines with the latest versions of an object? As you'll see some of the scripts listed in my file have more than one version number (version number is after the file extension). E.g. cdm_bri.pkb has... (2 Replies)
Discussion started by: Glyn_Mo
2 Replies

7. Shell Programming and Scripting

Display string at line number

I have a code here , which should display lines 6,10,14,18,35 of a text file #!/bin/ksh line=6 line=10 line=14 line=18 line=35 for i in 1 2 3 4 5 do val=`echo ${line}` act=`awk 'NR~/^($val)$/' db_CHECKOUT.txt` done; This code is not working. The purpose of the line below is... (3 Replies)
Discussion started by: njafri
3 Replies

8. UNIX for Dummies Questions & Answers

awk - display from line number to regex

Hi. Is there a way in awk to show all lines between a line number and the next line containing a particular regex? We can do these, of course: awk '/regex1/,/regex2/' filename awk 'FNR > X && FNR < Y' filename But can they be combined? Thanks. (3 Replies)
Discussion started by: treesloth
3 Replies

9. Shell Programming and Scripting

Appending line number to each line and getting total number of lines

Hello, I need help in appending the line number of each line to the file and also to get the total number of lines. Can somebody please help me. I have a file say: abc def ccc ddd ffff The output should be: Instance1=abc Instance2=def Instance3=ccc Instance4=ddd Instance5=ffff ... (2 Replies)
Discussion started by: chiru_h
2 Replies

10. UNIX for Dummies Questions & Answers

how to display line number for tail -f

Hi, Just wonder if there is any quick way to display line number when monitoring a log file with tail -f? (4 Replies)
Discussion started by: iengca
4 Replies
Login or Register to Ask a Question