03-19-2008
sed skipping the last line in a file
Hello All,
I have a file like this:
PART A1
PART A2
%
PART B1
PART B2
The last line in the file (PART B2) does not end with a new line. i.e <EOF> immediately follows "PART B2".
Here is my problem: I want to print everything after '%'.
So, I tried:
sed '1,/%/ d' [file_name].
This works beautifully on Linux. But on Solaris, the last line is never printed. I suspect since it does not end with a newline, sed quits abruptly after encountering <EOF>.
Any ideas on how to get around this problem?
Thanks,
Ali
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi,
Consider following file with input:
`YFLG:NC^Byad_insert constraint {id=600104470} {profile=GENDER == 2} {profile=BEHAVIOR == 17} {profile=SITEATTR_MULT == siteid:211051} {profile=AGE in }
yad_insert ad {id=1718286093336959379} {type=R}
^AYFLG:YOO^Byad_insert constraint {id=600104471}... (1 Reply)
Discussion started by: bvids
1 Replies
2. Shell Programming and Scripting
I have files of more than 10K lines that I need to delete lines that contain a pattern, but I want to keep the first few lines intact. Can this be done with sed? (7 Replies)
Discussion started by: tkg
7 Replies
3. Shell Programming and Scripting
Hi
Trying to remove line from file log_January_1_array and code below doesn't work.
$(sed -e '/"$n"/d' <log_January_1_array >log_January_1_array_1)
sed doesn't know what is in $n variable and nth happens.
Please advice how to make sed running this.
thx (2 Replies)
Discussion started by: presul
2 Replies
4. Shell Programming and Scripting
I have two files.
Fileone contains
text string one
text string two
text string three
Filetwo contains
Name:
Address:
Summary:
Name:
Address:
Summary:
Name:
Address:
Summary:
I would like to use sed to read each line of file one and put it at the end of the summary line of file... (3 Replies)
Discussion started by: dolacap
3 Replies
5. Shell Programming and Scripting
I have a file, from where I need to extract some data. But, the condition is like following :
The script will read line by line,while checking if any line starts with 'MN'. If found true, it looks for if the immediate line starts with 'PQ' or not. If its true then, extract few fields from that... (1 Reply)
Discussion started by: mady135
1 Replies
6. Shell Programming and Scripting
Dear all,
I am trying to extract a number from a line in one file (task 1), duplicate another file (task 2) and replace all instances of the strings 300, in duplicated with the extracted number (task 3). Here is what I have tried so far:
for ((k=1;k<4;k++)); do
temp=`sed -n "${k}p"... (2 Replies)
Discussion started by: mnaqvi
2 Replies
7. Shell Programming and Scripting
Hello,
First please excuse me for my poor english, i am french. Thank you for reading this thread and potentially helping me.
I have a 300ko file of one line (without any \n)
I want to create a new flat file with \n every 592 characters
I tried with some sed commands, but i am not very... (10 Replies)
Discussion started by: marcello_fr
10 Replies
8. UNIX for Dummies Questions & Answers
I have 2 files with the same header and need to append them and put the result in a 3rd file
the 2 files has the same header and while appending i want to skip the second file header and need the result to be put in a third file
Normally, this would work
Cat file1 file2 >> file3....But how... (5 Replies)
Discussion started by: saggiboy10
5 Replies
9. Shell Programming and Scripting
i have few lines in a file... i am reading them in a while loop so a particular line is held is $line1.. consider a modified line is held in $line2.... i want to replace $line1 with $line2 in the same file... how to do it..?
i have come up till the below code
sed "s/$line1/$line2/g" tmpfile.sql... (5 Replies)
Discussion started by: vivek d r
5 Replies
10. Shell Programming and Scripting
Sed command to replace a line in a file using line number from the output of a pipe.
Is it possible to replace a whole line piped from someother command into a file at paritcular line...
here is some basic execution flow..
the line number is 412
lineNo=412
Now i have a line... (1 Reply)
Discussion started by: vivek d r
1 Replies
LEARN ABOUT DEBIAN
mail::server::imap4::search
Mail::Server::IMAP4::Search(3pm) User Contributed Perl Documentation Mail::Server::IMAP4::Search(3pm)
NAME
Mail::Server::IMAP4::Search - select messages within a IMAP folder (not completed)
INHERITANCE
Mail::Server::IMAP4::Search
is a Mail::Box::Search
is a Mail::Reporter
SYNOPSIS
use Mail::Box::Manager;
my $mgr = Mail::Box::Manager->new;
my $folder = $mgr->open('imap4:Inbox');
my $filter = Mail::Server::IMAP4::Search->new
( ...to be defined...
);
my @msgs = $filter->search($folder);
if($filter->search($message)) {...}
DESCRIPTION
THIS PACKAGES IS NOT IMPLEMENTED YET... (it's waiting for a volunteer)
METHODS
Constructors
Mail::Server::IMAP4::Search->new(OPTIONS)
-Option --Defined in --Default
binaries Mail::Box::Search <false>
decode Mail::Box::Search <true>
delayed Mail::Box::Search <true>
deleted Mail::Box::Search <false>
deliver Mail::Box::Search undef
in Mail::Box::Search 'BODY'
label Mail::Box::Search undef
limit Mail::Box::Search 0
log Mail::Reporter 'WARNINGS'
logical Mail::Box::Search 'REPLACE'
multiparts Mail::Box::Search <true>
trace Mail::Reporter 'WARNINGS'
binaries => BOOLEAN
decode => BOOLEAN
delayed => BOOLEAN
deleted => BOOLEAN
deliver => undef|CODE|'DELETE'
in => 'HEAD'|'BODY'|'MESSAGE'
label => STRING
limit => NUMBER
log => LEVEL
logical => 'REPLACE'|'AND'|'OR'|'NOT'|'AND NOT'|'OR NOT'
multiparts => BOOLEAN
trace => LEVEL
Searching
$obj->inBody(PART, BODY)
See "Searching" in Mail::Box::Search
$obj->inHead(PART, HEAD)
See "Searching" in Mail::Box::Search
$obj->search(FOLDER|THREAD|MESSAGE|ARRAY-OF-MESSAGES)
See "Searching" in Mail::Box::Search
$obj->searchPart(PART)
See "Searching" in Mail::Box::Search
The Results
$obj->printMatch([FILEHANDLE], HASH)
See "The Results" in Mail::Box::Search
Error handling
$obj->AUTOLOAD()
See "Error handling" in Mail::Reporter
$obj->addReport(OBJECT)
See "Error handling" in Mail::Reporter
$obj->defaultTrace([LEVEL]|[LOGLEVEL, TRACELEVEL]|[LEVEL, CALLBACK])
Mail::Server::IMAP4::Search->defaultTrace([LEVEL]|[LOGLEVEL, TRACELEVEL]|[LEVEL, CALLBACK])
See "Error handling" in Mail::Reporter
$obj->errors()
See "Error handling" in Mail::Reporter
$obj->log([LEVEL [,STRINGS]])
Mail::Server::IMAP4::Search->log([LEVEL [,STRINGS]])
See "Error handling" in Mail::Reporter
$obj->logPriority(LEVEL)
Mail::Server::IMAP4::Search->logPriority(LEVEL)
See "Error handling" in Mail::Reporter
$obj->logSettings()
See "Error handling" in Mail::Reporter
$obj->notImplemented()
See "Error handling" in Mail::Reporter
$obj->report([LEVEL])
See "Error handling" in Mail::Reporter
$obj->reportAll([LEVEL])
See "Error handling" in Mail::Reporter
$obj->trace([LEVEL])
See "Error handling" in Mail::Reporter
$obj->warnings()
See "Error handling" in Mail::Reporter
Cleanup
$obj->DESTROY()
See "Cleanup" in Mail::Reporter
$obj->inGlobalDestruction()
See "Cleanup" in Mail::Reporter
DIAGNOSTICS
Error: Package $package does not implement $method.
Fatal error: the specific package (or one of its superclasses) does not implement this method where it should. This message means that
some other related classes do implement this method however the class at hand does not. Probably you should investigate this and
probably inform the author of the package.
SEE ALSO
This module is part of Mail-Box distribution version 2.105, built on May 07, 2012. Website: http://perl.overmeer.net/mailbox/
LICENSE
Copyrights 2001-2012 by [Mark Overmeer]. For other contributors see ChangeLog.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See
http://www.perl.com/perl/misc/Artistic.html
perl v5.14.2 2012-05-07 Mail::Server::IMAP4::Search(3pm)