Have to exclude the first and last line of the file : help me


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Have to exclude the first and last line of the file : help me
# 1  
Old 12-22-2010
Have to exclude the first and last line of the file : help me

hi , i am very new to perl . scriptting.. pllease can any one help me ...pleaseeeeeee


i ll have a file which look likes
Code:
123 |something |567 
456 |welcome |789 
457 |inboxpost |790 
. 
. 
123 |something |567


i have to execute all the lines in the file except the first and the last.///
can u give me idea and how to proceed with this...

Last edited by Scott; 12-22-2010 at 12:56 PM.. Reason: Code tags; formatting.
# 2  
Old 12-22-2010
Code:
sed -n '$!{2,$p;}' yourfile

Code:
grep -v ^123 yourfile

This User Gave Thanks to ctsgnb For This Post:
# 3  
Old 12-22-2010
Code:
sed -n '2,$p' input_file | sed '$d'

This User Gave Thanks to panyam For This Post:
# 4  
Old 12-22-2010
Code:
awk 's{print s}NR-1{s=$0}' file

This User Gave Thanks to Franklin52 For This Post:
# 5  
Old 12-22-2010
Code:
sed '1d;$d' file

This User Gave Thanks to Scrutinizer For This Post:
# 6  
Old 12-22-2010
ya thanks for the reply.. but can u tell me can i use this command inside a perl script ?? wont it give error /
# 7  
Old 12-22-2010
remove first row
perl -pi -e '$_ = "" if ($. == 1);' ${UR_FILE}
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Exclude First Line when awk

Hi there, Where do I add the !NR==1 into the awk statement such that it ignores the first line . awk '/1.2 Install/ {P=0} /1.1 Apply/ {P=1} P {print FILENAME, $0} ' solarisappsummary.txt solarisdbsummary.txt solaris_websummary.txt (12 Replies)
Discussion started by: alvinoo
12 Replies

2. UNIX for Dummies Questions & Answers

Exclude file with tar

hi, i am trying to use a exclude file to exclude some file directories while making a tar archive. This is my command: tar -pcvf orahome10gR2.tar.gz db_1 -X /home/oracle/excludeFile.txt /home/oracle/ when i execute it, it seem to be tar-ing. But once is done, i cd to /home/oracle and could... (2 Replies)
Discussion started by: redologger
2 Replies

3. UNIX for Dummies Questions & Answers

Exclude new line character while searching

Hi, I have a log file and want to search "0.48976360737438795" with excluding new line character. Currently i am using the following command: cat LogFile.log | tr -d '\n' | grep '0.48976360737438795' This command giving me the response if file size is small but if i am using a big file... (11 Replies)
Discussion started by: ankit jain
11 Replies

4. Shell Programming and Scripting

Exclude a file or not in

Hi Gurus. I have a directory and i receive many files with extension .log. I processed the file as i get it. i want to process all the files except one which i know i don't want to process. cd /backup/temp/rajesh/PACS #--- directory , under this i have below files... (1 Reply)
Discussion started by: guddu_12
1 Replies

5. Shell Programming and Scripting

exclude blank line

hi, how can i exclude blank line along with #, in the below command. crontab -l|grep -v "^#" |wc -l thx (3 Replies)
Discussion started by: bang_dba
3 Replies

6. Ubuntu

[Solved] Using Find with an exclude/exclude file

I am familiar with using tar and exclude/include files: tar zcf backup.dirs.tgz --files-from=include.mydirs --exclude-from=exclude.mydirs --no-recursion but was wondering if I could use find in the same way. I know that you can just specify the directories to exclude but my list is... (2 Replies)
Discussion started by: metallica1973
2 Replies

7. Shell Programming and Scripting

Perl exclude directories in command line

Hi, I use find command to list all the files in a directory and its sub-directories, but the problem is to exclude certain directories during search. Can i give the directory names in command line to skip them and search rest of the directories? For example i have directories: test ../test1... (1 Reply)
Discussion started by: nmattam
1 Replies

8. Shell Programming and Scripting

ls to exclude file

I have cgicsave.env and cgic*, but I want to print cgic* value but NOT cgicsave.env Thanks (9 Replies)
Discussion started by: xs2punit
9 Replies

9. UNIX for Dummies Questions & Answers

exclude columns with a matching line pattern

Hi , I have 5 columns total and am wanting to search lines in columns 3-5 and basically grep -v patterns that match 'BBB_0123' 'BVG_0895' 'BSD_0987' Does anyone know how to do this? I tried combining grep -v with grep -e but, it didn't work. Thanks! (5 Replies)
Discussion started by: greptastic
5 Replies

10. Shell Programming and Scripting

exclude a line

Hi, thanks for your help. I wrote this script : # ! /bin/sh file=snapshot.txt cat $file | while read line ; do { myvariable=`grep "Nombre de ROLLBACK internes" |sed 's/.*.=//'` echo $myvariable } done It looks in a file "snapshot.txt" for the lines containing "Nombre de ROLLBACK... (3 Replies)
Discussion started by: big123456
3 Replies
Login or Register to Ask a Question