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
# 8  
Old 12-23-2010
ya thank u for reply but can u make me clear whether can i use these all commands inside a perl script

---------- Post updated 12-23-10 at 05:56 AM ---------- Previous update was 12-22-10 at 10:09 PM ----------

Last edited by vishwakar; 12-23-2010 at 12:40 PM..
# 9  
Old 12-23-2010
How about:
Code:
perl -ne 'print unless $.==1 || eof ' infile

or the other way around:
Code:
perl -pe '$_="" if $.==1 || eof ' infile


Last edited by Scrutinizer; 12-23-2010 at 08:34 AM..
# 10  
Old 12-23-2010
can i use this inside a perl script .??. i dont want a command in a command window
# 11  
Old 12-23-2010
Code:
blabla code

open FF,"<file";
   while (<FF>){
      print "$_" unless ($_ =~ "^123");
   }
close FF;

blabla code

R0H0N
# 12  
Old 12-23-2010
can u tell me what it will do ? in the above logic u mentioned

($_ =~ "^123");
# 13  
Old 12-23-2010
Quote:
Originally Posted by vishwakar
($_ =~ "^123");
That expression is true if the line in $_ starts with the string "123".
# 14  
Old 12-24-2010
ya .. i am still struggling with this code.. i want only in perl as awk,sed.. and all commands wont work inside a perl script.. is there any other way... please help me
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