Here is a looper to remove more than one consecutive blank lines, which illustrates the concept:
I put my sed script on its own lines for clarity. If you want to check for lines with only spaces and tabs, that scrubbing can be done upstream in one line or inserted here as two lines. That is why I say sed loopers are usually best kept separate from non-loopers. There is no single place to filter and translate single lines in a looper without redundant processing, like substituting on each line twice.
Narrative:
Create a branch target,
if last line branch to end of script (print buffer and exit) as $N usually tosses the last line,
get the next line on end of buffer as '\nLine_2',
if both lines are empty, remove one,
if line was removed branch back to loop,
print the first line,
remove the first line and
branch back to loop.
Last edited by DGPickett; 07-10-2013 at 06:00 PM..
hello!
I have a few sed commands
sed '/^$/d' < $1 > tmp.t
sed '/^ \{3,\}/d' < tmp.t > tmp1.txt
.....
how can I write them in a single line?
sed '/^$/d' < $1 > | '/^ \{3,\}/d' < $1 > tmp1.txt
any idea?
thanks. (5 Replies)
New to shell scripting.
I can't get my script to execute multiple commands.
Here's the code. It's a menu script.
#!/bin/ksh
clear
print "SDE MENU"
PS3="SDE MENU, enter choice:"
select clean_menu in "tasdedev instance 5151" "orkindev instance 5155" "tasdetst
instance 5157" "orkinsys... (1 Reply)
Hello ,
I am trying to print the footer of evry file in the given directory with xargs command like follows
ls -1 | xargs -I {} gzcat {} | tail -1
now problem with this is only last file foooter is getting printed as " | tail -1 " is getting executed for the last file.
I know this can... (4 Replies)
I am checking that a file is older than a reference file that I build with a touch command before processing it. If it is not old enough, I want to sleep for an hour and check again.
My problem is if it is old enough to process, I want to exit when I am done, but I cannot find a way to exit... (2 Replies)
Hi,
Iam trying to code in java and wanted to run the commands in the Unix remote servers. I have the following code to run multiple GREP commands in a single session.
But when i execute this, the first command executes successfully, whereas from the next line it says
"Exception Occured... (1 Reply)
Requirement:
Run a shell script with below inputs
file name
checksum
path
the script should go to multiple servers (around 35) and verify the input cksum and if there is a mismatch display a simple message to the user that cksum verification failed.
host details, user id /... (1 Reply)
for example:
I'm greping the process where i can get the location of the file
$ ps -ef | grep LLAWP | awk {'print $9'} | tail -1
/Hostname/ihs/INSTANCE2/conf/WebAgent.conf
then I need to display second line of WebAgent.conf file:
$ cat /Hostname/ihs/INSTANCE1/conf/WebAgent.conf | head... (2 Replies)
Hi
I need to write a script to ssh through several hops (e.g. HostA-HostB-HostC-HostD), where Host A does not have direct assess to HostC ; HostB cannot access HostD directly.
when I ssh 3 hops and run command with arg1, arg2 and redirect the output to a file, e.g.
HostA> ssh -t HostB ssh -t... (3 Replies)
I have a text file and i want to run 3 sed commands for the lines entered by the user using perl script. I am doing this manually till now.
need some help with this
The sed commands I have to use are :
sed -i "s/{+//" error.txt
sed -i "s/+}//" error.txt
sed -i "s/\//g" error.txt... (5 Replies)
Discussion started by: utkarshkhanna44
5 Replies
LEARN ABOUT OSX
filtercalltree
filtercalltree(1) BSD General Commands Manual filtercalltree(1)NAME
filtercalltree -- Filter or prune a call tree file generated by sample or malloc_history
SYNOPSIS
filtercalltree call-tree-file [-invertCallTree] [-pruneCount count] [-pruneMallocSize size] [-chargeSystemLibraries]
[-chargeLibrary libraryName] [-keepBoundaries]
DESCRIPTION
filtercalltree reads a file containing a call tree, as generated by the sample(1) or malloc_history(1) commands, and filters or prunes it as
specified by the options.
OPTIONS -invertCallTree Print the call tree from hottest to coldest stack frame.
-pruneCount count Remove branches of the call tree that have count less than count
-pruneMallocSize size Remove branches of the call tree that have malloc size less than size, such as 500K or 1.2M.
-chargeSystemLibraries Remove stack frames from all libraries in /System and /usr, while still charging their cost to the caller.
-chargeLibrary library-name
Remove stack frames from library-name, while still charging their cost to the caller. This argument can be repeated
for multiple libraries.
-keepBoundaries When charging libraries to callers, keep the top call into excluded libraries.
SEE ALSO malloc_history(1), sample(1)BSD May 7, 2011 BSD