I'm trying to find the cause of memory leaks in my java application. I need to get a heap dump for a process that is in a long GC-cycle. Jmap isn't working in this case both because app is hanged and because heap is very large.
Unfortunately, jmap throws UnknownOopException on the core dump I took. I suppose that it isn't correct to take core dump during GC.
In my bash script I want to echo lines in a file and ensure no blank lines are echoed:
Code:
for i in $(cat txt)
do
echo $i | sed 's/|/ /g;s/ SEARCHTERM$//g;s/ /\r\n/g;s/^$/d'
done
Keep in mind this is a fragment so ignore the fact that the for loop is not closed.
Part 1
Say I have a command my_command that outputs multiple lines.
I have a following bash script I encountered on the web that prints the power set of a given lines of elements.
p() { [ $# -eq 0 ] && echo || (shift; p "$@") |
while read r ; do echo -e "$1 $r\n$r"; done }
after the first && there is echo that does not have any argument.
Here is the code to test it:
p $(echo -e "1\n2\n3")
I have a command returning multiple lines.
Some times I want to append a file with multiple lines via echo.
Im reading the man page for echo and see the \n option, but I cant get the syntax to give me what I want.
Code:
echo "#" Some User Defined Aliases \n GREP_OPTIONS='grep --color=always' > ~/ngo
that gives me one line at the end of a file where I want 2 lines.
#!/bin/bash
function abc() # wait for some event to happen, can be terminated by other process
{
sleep 3333
}
echo "PID: $$"
abc &
echo "PID: $$"
I need to retrieve the pid of this function, but the echo prints the same string.
If I'm not going to put abc() out of this script, is it possible to get it's pid and terminate that function?
Hi All,
Need a small help in writing a shell script which can delete a few lines from a file which is currently being used by another process.
File gets appended using tee -a command due to which its size is getting increased.
Contents like :
Code:
[INFO] 25/09/2012 05:18 Run ID:56579677-1
My requirement is to remove lines which are more than 1 month old...
if i want to display "aaa" on screen:
(1)$: echo aaa | cat ... works OK
(2)$: echo aaa | ( cat ) ... works OK
(3)$: echo aaa | ( cat & ) ... NOT working
(4)$: ( echo aaa & ) | cat ... works OK
(5)$: echo aaa | ( cat <&0 & ) ... works ok in BASH (but not in SH)
(6)$: echo aaa | ( cat <&3 & ) 3<&0 ...