|
|
|
|
|
|
| Author |
Message |
agarwal.prateek@gmail.com *nix forums beginner
Joined: 01 Aug 2005
Posts: 3
|
Posted: Fri Jun 09, 2006 3:55 am Post subject:
Re: sed, remove last new line
|
|
|
| Quote: | Then why post in a newsgroup for the AWK programming language?
because I couldnt find a separate group for sed and saw other posts |
related to sed, will try comp.unix.shell
and
sed '$,$s/^.*$/whatever/' test
removes the last "line" not the last new-line character. |
|
| Back to top |
|
 |
Chris F.A. Johnson *nix forums Guru
Joined: 20 Feb 2005
Posts: 2268
|
Posted: Fri Jun 09, 2006 5:26 am Post subject:
Re: sed, remove last new line
|
|
|
On 2006-06-09, quarkLore wrote:
| Quote: | Then why post in a newsgroup for the AWK programming language?
because I couldnt find a separate group for sed and saw other posts
related to sed, will try comp.unix.shell
and
sed '$,$s/^.*$/whatever/' test
removes the last "line" not the last new-line character.
|
Which is what you said you wanted:
| Quote: | I have to use "sed and sed only" to either remove the last line or
if possible replace the last line with some character.
|
--
Chris F.A. Johnson, author <http://cfaj.freeshell.org>
Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
===== My code in this post, if any, assumes the POSIX locale
===== and is released under the GNU General Public Licence |
|
| Back to top |
|
 |
Alan Connor *nix forums Guru
Joined: 28 Feb 2005
Posts: 481
|
Posted: Sat Jun 10, 2006 10:27 pm Post subject:
CFAJ Forgery? (was: Self importance of U/L[nix] ?)
|
|
|
On comp.os.linux.misc, in <0tmrl3-e2t.ln1@xword.teksavvy.com>, "Chris F.A. Johnson" wrote:
| Quote: | Path: text.usenetserver.com!atl-c01.usenetserver.com!news.usenetserver.com!news2.euro.net!news.mailgate.org!nntp.infostrada.it!area.cu.mi.it!news.newsland.it!eleonora.aioe.org!emma.aioe.org!aioe.org!xword.teksavvy.com!news
|
$ host xword.teksavvy.com
xword.teksavvy.com does not exist, try again
Only trolls post through aioe.org.
And only trolls falsify their path header.
Wait:
| Quote: | From: "Chris F.A. Johnson" <cfajohnson@gmail.com
|
Anonymous and throwaway emailaddress.
Isn't there an SMTP server at teksavvy.com? What's the problem
with using that?
Is this really CFAJ?
Why would Chris feed this troll and use a crummy newsserver
like aioe and falsify his path header and use an anonymous and
throwaway email address?
| Quote: | Newsgroups: comp.os.linux.misc
Subject: Re: Self importance of U/L[nix] ?
Date: Sat, 10 Jun 2006 16:33:04 -0400
Organization: Aioe.org NNTP Server
Lines: 56
Message-ID: <0tmrl3-e2t.ln1@xword.teksavvy.com
References: <pan.2006.06.09.22.08.43.231099@absamail.co.za
Reply-To: cfajohnson@gmail.com
NNTP-Posting-Host: rzptHS7pJmHxAyCc6QiecQ.user.aioe.org
X-Complaints-To: abuse@aioe.org
|
An utter waste of time. aioe is run by a troll, for trolls.
And I'm not convinced this was even posted through aioe anyway.
That is not what the first part of aioe's path header customarily
looks like.
| Quote: | User-Agent: slrn/0.9.8.1 (Linux)
Xref: usenetserver.com comp.os.linux.misc:542622
X-Received-Date: Sat, 10 Jun 2006 16:33:09 EDT (text.usenetserver.com)
|
Alan
--
http://home.earthlink.net/~alanconnor/contact.html
Other URLs of possible interest in my headers. |
|
| Back to top |
|
 |
Michael Paoli *nix forums Guru Wannabe
Joined: 10 Oct 2005
Posts: 107
|
Posted: Sun Jun 11, 2006 10:23 pm Post subject:
Re: sed, remove last new line
|
|
|
quarkLore wrote:
| Quote: | and
sed '$,$s/^.*$/whatever/' test
removes the last "line" not the last new-line character.
|
Well, it replaces the last line, but doesn't strip the newline
character, as would the equivalent:
sed -e '$s/^.*$/whatever/' test
sed(1) probably isn't the correct tool to use if one wants to strip
the last newline character from the last line ... unless it just
happens to be the case that one wants precisely nothing output in
place of that last line, in which case:
sed -e '$d'
will delete the last line.
Using awk(1) or perl(1) would easily handle removing the newline
character from the last line in the more general case, e.g.:
awk '{if(NR>1)print l;l=$0};END{if(NR>=1)printf("%s",l);}'
perl -e '{$/="";$_=<>;chomp;print;}'
If one wants whatever to replace the last line, including replacing
the ending newline with nothing:
awk '{if(NR>1)print l;l=$0};END{if(NR>=1)printf("whatever");}'
perl -e '{$/="";$_=<>;chomp;s/[^\n]*$/whatever/o;print;}' |
|
| Back to top |
|
 |
bsh *nix forums Guru Wannabe
Joined: 01 Mar 2005
Posts: 125
|
Posted: Tue Jul 04, 2006 1:44 am Post subject:
Re: Bourne shell read question
|
|
|
Chris F.A. Johnson wrote:
| Quote: | On 2006-06-28, swangdb wrote:
...
It is the while loop, not the disc access that is slow.
|
No, it is the way that redirection is implemented within
a while (or any other) loop, that redundant syscalls are
slowing down the while loop itself.
The while loop (unfortunately) creates a new process
environment to execute the loop body, thereby
presumably copying the environment (and FDs)
multiple times.
| Quote: | From David Butcher's investigation, "Speeding Up Your
UNIX Shell Scripts" at |
http://www.los-gatos.ca.us/davidbu/faster_sh.html :
"Conclusion: a 500% speedup [results from] use of file
descriptor manipulation, instead of [by using] input
redirection ... in a while loop."
Try the workaround demonstrated in the file mentioned above.
=Brian |
|
| Back to top |
|
 |
James *nix forums Guru
Joined: 09 Jun 2003
Posts: 306
|
Posted: Tue Jul 18, 2006 5:40 pm Post subject:
Re: HP-UX 11.x and Legato Networker 5.5
|
|
|
James wrote:
| Quote: | Hello,
I work for a company who uses Legato Networker to backup their HP-UX
systems.
The problem is Legato. It seems that on one particular server, Legato
wants to fail at least once a week. Multiple sites are supported
solely by me, and I have spent many weeks restoring Legato directories
when it crashes or encounters wierd problems, and then updating the
indexes and checking on the settings to make sure nothing has changed
(online and offline notes are kept on the settings for each server).
The thing that makes this difficult is that I am not allowed to install
software such as snort, sudo or tripwire. Furthermore, it seems that
although a limited number of people know the root password (i.e 1-2
people plus myself, as I am root), certain things are happening that
would require the root password. Physical security is not optimal, and
I have to sleep a small number of hours to keep my sanity, otherwise I
would be onsite or connected otherwise all the time.
A recent issue that concerns me is the numbe of times it's primary
daemons disappear from the process table, forciong me to go in and
restart it manually and watch the system. I had written a script to
automatically check and restart the processes, but it didn't work
correctly so it was removed from cron.
No signs of external intrusion are found, so it seems to me it would be
a system issue or internal access to the console for some odd reason to
only kill this application nightly this week.
Here is the script that was written:
#!/bin/sh
outfile="/nsr_up.txt"
touch $outfile
echo "Number of processes on host total: `ps -ef | grep nsr | wc -l`"
$outfile
ps -ef | grep nsrd
if [ "$?" -eq 0 ]; then
echo "Exit value of last command was unsuccessful" >> $outfile
/opt/networker/bin/nsrd
/opt/networker/bin/nsrexecd
echo "" >> $outfile
echo "NSR processes started at `date`" >> $outfile
echo "Number of NSR process running on host total: `ps -ef | grep nsr
| wc -l`" >> $outfile
ps -ef | grep nsr >> $outfile
sleep 1
fi
mailx root@myhost.ext < $outfile
mailx me@externaladdr.ext < $outfile
rm $outfile
Can someone point out why:
1. These Legato issues are occurring
2. Why this script is overloading processes (nsrd loads at least one
nsrexecd and two nsrexex processes when started)
Thanks.
|
BTW, the primary shell is /bin/sh.
A few other notes that I've encountered.
Legato continually has issues with Cleaning Tapes and predefined slots,
Read error: no such device or addess,
The client one week decides it's a server resulting in a license issue
that was resolved
Thanks in advance. |
|
| Back to top |
|
 |
Ines Schmitt *nix forums beginner
Joined: 18 Jul 2006
Posts: 1
|
Posted: Tue Jul 18, 2006 7:06 pm Post subject:
Re: HP-UX 11.x and Legato Networker 5.5
|
|
|
X-No-archive: yes
Hi James,
we are running Networker 7.1.3 on HPUX Itanium and beside the problem of
the non-existing persistent binding solution for tape devices it is
running well. Version 5.5 seems to be rather old, since 7.3.1 is the
current release. I am sorry that I could not help with your specific
problem but I would like to give You a link to a mailinglist where many
Legato networker users gave really helpful tips. I guess You will find a
helpful answer there. HTH
http://www.lsoft.com/scripts/wl.exe?SL1=NETWORKER&H=LISTSERV.TEMPLE.EDU
Ines
Am 18.07.2006 hast Du geschrieben:
| Quote: | James wrote:
Can someone point out why:
1. These Legato issues are occurring
2. Why this script is overloading processes (nsrd loads at least one
nsrexecd and two nsrexex processes when started)
Thanks.
BTW, the primary shell is /bin/sh.
A few other notes that I've encountered.
Legato continually has issues with Cleaning Tapes and predefined slots,
Read error: no such device or addess,
The client one week decides it's a server resulting in a license issue
that was resolved |
|
|
| Back to top |
|
 |
Google
|
|
| Back to top |
|
 |
|
|
The time now is Mon Dec 01, 2008 8:53 pm | All times are GMT
|
|
Loans | Per Insurance | Credit Cards | Myspace Layouts | Mortgage
|
|
Copyright © 2004-2005 DeniX Solutions SRL
|
|
|
|
Other DeniX Solutions sites:
Unix/Linux blog |
electronics forum |
medicine forum |
science forum |
|
|
Privacy Policy
|
Powered by phpBB © 2001, 2005 phpBB Group
|
|