Sponsored Content
Full Discussion: Problem with sed in perl!!
Top Forums Shell Programming and Scripting Problem with sed in perl!! Post 302446386 by abhisharma23 on Wednesday 18th of August 2010 12:55:21 PM
Old 08-18-2010
Problem with sed in perl!!

Hi,
I am facing an issue with sed in perl. I have a file which has 2 header lines and one trailer line. I need to process the file without these headers and trailer. My file looks like :
File.txt:-
Code:
Header1
Header2
data1
data2
trailer

For removing header and trailer from file I am using the following command in perl file:
Code:
system (`sed '1d;2d;$d' File.txt > NewFile.txt`);

The problem is, when I am excuting this perl script it is just removing the Headers only and not the trailer from the file.
But when I am directly running this command on command line:
Code:
sed '1d;2d;$d' File.txt > NewFile.txt

It is running fine and is removing both headers and trailer from the file. Not sure, why the same command is working differently in perl??
Any help would be highly appreciated.
Thanks..


Moderator's Comments:
Mod Comment Please use code tags, thank you

Last edited by Franklin52; 08-18-2010 at 02:28 PM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Perl/Sed script help

Hi All, I would need to generate Oracle Inster scripts from an excel formatted spreadsheet as follows: This needs to be stripped as follows: REC 1, REC 2 etc are the separators of the records ... I beleive a pearl script can be written for this ... anything useful will be of... (8 Replies)
Discussion started by: sabyasm
8 Replies

2. Shell Programming and Scripting

[Perl] Accessing array elements within a sed command in Perl script

I am trying to use a script to replace the header of each file, whose filename are stored within the array $test, using the sed command within a Perl script as follows: $count = 0; while ( $count < $#test ) { `sed -e 's/BIOGRF 321/BIOGRF 332/g' ${test} > 0`; `cat 0 >... (2 Replies)
Discussion started by: userix
2 Replies

3. Shell Programming and Scripting

Convert sed to perl

Can anyone convert this from sed to perl: sed -n '/\var\/log/p' /etc/syslog.conf I think Ive looked at this to much....urgh.. Thanks Ben (5 Replies)
Discussion started by: bigben1220
5 Replies

4. Shell Programming and Scripting

Sed/Perl help

Some text is like this.... <table>This is first text.</table>mouse <table>This is second text</table>keyboard <table>This is third text</table>Pad I need to insert <a></a> between "mouse","keyboard","Pad". I it possible to do with sed/Perl ? Please help.. The text should look like... (8 Replies)
Discussion started by: gameboy87
8 Replies

5. Shell Programming and Scripting

Need Help with sed/perl !

In a file the content is 13 box google unix.com "he is google" hello "he is unix.com" - I need to replace each space char with "a" char but not inside the double quoted strings. So, the output must look like, 13aboxagoogleaunix.coma"he is google"ahelloa"he is unix.com"a- I tried with ... (9 Replies)
Discussion started by: gameboy87
9 Replies

6. Shell Programming and Scripting

re-Substitution Sed (or Perl)

I have a large text csv file that I'm working with. It will look something like this: D,",E",C O,"F,",I O,gh,R The second column always has a two digit random code (can be numbers, letters or any characters). When one of the characters happens to be a comma, the string is quoted. I want to... (5 Replies)
Discussion started by: beenny
5 Replies

7. Web Development

problem with exporting vairable from one perl cgi to another perl cgi script while redirecting.

Can anyone tell me how to export a variable from one perl CGI script to another perl cgi script when using a redirect. Upon running the login.pl the user is prompted to enter user name and password. Upon entering the correct credentials (admin/admin) the user is redirected to welcome page. My... (3 Replies)
Discussion started by: Arun_Linux
3 Replies

8. Shell Programming and Scripting

Perl/sed Escape Syntax Problem . . .

Greetings! I've run into this before; and am having a spot of trouble trying to figure out the way that Perl would prefer the following example syntax to be formed:#!/usr/bin/perl use strict; use warnings; use diagnostics; `sed -i 's/Hi Mom!\|Hi Dad!/Bye Everyone!/I' ./test.txt`;Perl... (5 Replies)
Discussion started by: LinQ
5 Replies

9. UNIX for Dummies Questions & Answers

sed Or Grep Problem OR Terminal Problem?

I don't know if you guys get this problem sometimes at Terminal but I had been having this problem since yesterday :( Maybe I overdid the Terminal. Even the codes that used to work doesn't work anymore. Here is what 's happening: * I wanted to remove lines containing digits so I used this... (25 Replies)
Discussion started by: Nexeu
25 Replies

10. Shell Programming and Scripting

Rewrite sed to perl or run sed in perl

I am having trouble re-writing this sed code sed -nr 's/.*del(+)ins(+).*NC_0{4}(+).*g\.(+)_(+).*/\3\t\4\t\5\t\1\t\2/p' C:/Users/cmccabe/Desktop/Python27/out_position.txt > C:/Users/cmccabe/Desktop/Python27/out_parse.txt in perl Basically, what the code does is parse text from two fields... (12 Replies)
Discussion started by: cmccabe
12 Replies
Image::ExifTool::AFCP(3)				User Contributed Perl Documentation				  Image::ExifTool::AFCP(3)

NAME
Image::ExifTool::AFCP - Read/write AFCP trailer SYNOPSIS
This module is used by Image::ExifTool DESCRIPTION
This module contains definitions required by Image::ExifTool to extract information from the AFCP trailer. Although the AFCP specification is compatible with various file formats, ExifTool currently only processes AFCP in JPEG images. NOTES
AFCP is a specification which allows meta information (including IPTC) to be appended to the end of a file. It is a poorly designed protocol because (like TIFF) it uses absolute offsets to specify data locations. This is a huge blunder because it makes the AFCP information dependent on the file length, so it is easily invalidated by image editing software which doesn't recognize the AFCP trailer to fix up these offsets when the file length changes. ExifTool will attempt to fix these invalid offsets if possible. Scanning for AFCP information may be time consuming, especially when reading from a sequential device, since the information is at the end of the file. In these instances, the ExifTool FastScan option may be used to disable scanning for AFCP information. AUTHOR
Copyright 2003-2010, Phil Harvey (phil at owl.phy.queensu.ca) This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. REFERENCES
<http://www.tocarte.com/media/axs_afcp_spec.pdf> SEE ALSO
"AFCP Tags" in Image::ExifTool::TagNames, Image::ExifTool(3pm) perl v5.12.1 2010-01-04 Image::ExifTool::AFCP(3)
All times are GMT -4. The time now is 07:43 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy