Hi Skrynesaver/MR.Bean/krishmaths,
Thanks all of your input , Please excuse Skrynesaver i didnt see the note top -b d 3 command worked fine, through more , cat -v and vi i didnt see control characters,
Thanks i tried tr -d [:cntrl:] also it removes the caret symbol and character like [7m,[m[K[m,[m[m , i am able to see that i hope i can remove using sed command.
I tried
perl -pne 's/\^\[\[\d*m\^?O?//g; s/\^\[\[K//g' input.txt
but didnt work , actually i am using ksh.
i tried using
perl -pne '$_ =~ s/[^[:ascii:]]//g; print;' YourTextFile
-- command worked but still [* character was available ^ was removed.
and
perl -ne '$_ =~ s/\P{isPrint}//g; print;' YourTextFile
Thanks All for your valuable inputs.
Thanks,
Regards,
karthikram
---------- Post updated 09-05-13 at 02:15 AM ---------- Previous update was 09-04-13 at 10:09 PM ----------
Hi ,
I am not sure, whether i can request for another query,
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
2961 aaaa_a 15 0 100m 3196 2624 S 0.0 0.0 0:01.10 ssh aaa_a@aaaaaa
12759 aaaa_a 16 0 100m 3188 2616 S 0.0 0.0 0:00.34 ssh aaa_a@aaaaaa
I need to take this output in html format i am unable to get $12 value which is the COMMAND value , if there is space it prints the start of the word and not printing the entire.
I am unable to find a way to
- print the file in pipe separted so that i can send to html
- i am unable to print the file in mail , where it is printing the whole file in single line.
I tried,
2. using while loop which array nothing is working to print line by line in the mail.
and the file is containing blank space after the 12th field COMMAND.
Please advise.
Thanks,
Regards,
karthikram
---------- Post updated at 02:56 AM ---------- Previous update was at 02:15 AM ----------
Hi,
- To print the top command output file in mail , i tried the below , but writing the entire file in a single line.
IFS='\n'
i=1
while read -A line; do
echo "${line[${i}]}"
i=$((i + 1))
done < top_list.txt >> mail.txt
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 2961 aaaa_a 15 0 100m 3196 2624 S 0.0 0.0 0:01.10 ssh aaa_a@aaaaaa 12759 aaaa_a 16 0 100m 3188 2616 S 0.0 0.0 0:00.34 ssh aaa_a@aaaaaa
- To record the top command output file in html format, the 12th field COMMAND value which has space so while appending to html more number of rows are creating instead of 12 field expected.
echo -e "<table border="0" cellpadding="0" cellspacing="0">" >> output_2.html
cat top_list.txt | head -1 > top_list.txt_temp
awk 'BEGIN{RS="\n";FS="\n";}
{
print "<TR>";
for (i = 1; i <= NF; i++)
{print "<TH width=\"100%\">" $i "</TH>";}
print "</TR>";
print "\n";
}' top_list.txt_temp >> output_2.html
echo -e "<tbody id="data">" >> output_2.html
rm -f top_list.txt_temp
more +2 top_list.txt > top_list.txt_temp
awk 'BEGIN{RS="\n";FS="\n";}
{
print "<TR>";
for (i = 1; i <= NF; i++)
{print "<TD width=\"100%\">" $i "</TD>";}
print "</TR>";
print "\n";
}' top_list.txt_temp >> output_2.html
echo -e "</tbody></table>" >> output_2.html
echo -e "<br>" >> output_2.html
echo -e "</body></html>" >> output_2.html
and 1 more thing , file is containing blank space after 12th field.
and Is there any approach to get the top command output in pipe separated file.
Please advise how i need to workaround.
Thanks,
Regards,
karthikram
---------- Post updated at 10:11 AM ---------- Previous update was at 02:56 AM ----------
Hi,
could anyone please advise, i was trying to get top command file into html where 12th field containing space , i am not sure to frame exact awk to command to accomadate the value inside 12th field instead of more fields after it.
Thanks,
Regards,
karthikram