Sponsored Content
Top Forums Shell Programming and Scripting Request for advise on how to remove control characters in a UNIX file extracted from top command Post 302850159 by MR.bean on Wednesday 4th of September 2013 04:51:12 AM
Old 09-04-2013
Code:
bash-3.2$ cat input.txt
^[[7m  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND                                                                                         ^[[m^O^[[K
^[[m^O12759 aaaa_a    16   0  100m 3188 2616 S  0.0  0.0   0:00.23 xxx aaaa_axxxxxx                                                                               ^[[m^O
^[[m^O24435 aaaa_a    16   0  100m 3200 2624 S  0.0  0.0   0:00.19 xxx aaaa_axxxxxx                                                                               ^[[m^O
^[[m^O25623 aaaa_a    15   0  100m 3192 2624 S  0.0  0.0   0:00.28 xxx aaaa_axxxxxx                                                                               ^[[m^O
^[[m^O29634 aaaa_a    16   0  100m 3204 2632 S  0.0  0.0   0:00.35 xxx aaaa_axxxxxx                                                                               ^[[m^O

bash-3.2$ perl -pne 's/\^\[\[\d*m\^?O?//g; s/\^\[\[K//g' input.txt
  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND                                                                                         
12759 aaaa_a    16   0  100m 3188 2616 S  0.0  0.0   0:00.23 xxx aaaa_axxxxxx                                                                               
24435 aaaa_a    16   0  100m 3200 2624 S  0.0  0.0   0:00.19 xxx aaaa_axxxxxx                                                                               
25623 aaaa_a    15   0  100m 3192 2624 S  0.0  0.0   0:00.28 xxx aaaa_axxxxxx                                                                               
29634 aaaa_a    16   0  100m 3204 2632 S  0.0  0.0   0:00.35 xxx aaaa_axxxxxx

This User Gave Thanks to MR.bean For This Post:
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Remove control characters

Hi, When I do a man and save it into a file, I end up getting a lot of control characters. How can I remove them?? I tried this: /1,$ s/^H//g But I get an error saying "no previous regular expression". Can someone help me with this. Thanks, Aravind (5 Replies)
Discussion started by: aravind_mg
5 Replies

2. Programming

Identifying and removing control characters in a file.

What is the best method to identify an remove control characters in a file. Would it be easier to do this in Unix or in C. (0 Replies)
Discussion started by: oracle8
0 Replies

3. Shell Programming and Scripting

Which one is faster to remove control m characters?

I have a file with millions of records...Before I experiment, I would like to know which one is faster. Both the commands work absolutely fine on a smaller set of records. Please advice. sed 's/^M//g' ${INPUT_FILE} > tmp.txt mv tmp.txt ${INPUT_FILE} tr -d "\15" < ${INPUT_FILE} > ... (11 Replies)
Discussion started by: madhunk
11 Replies

4. Shell Programming and Scripting

Hidden control characters in a Unix Text File!

Can anyone seem to know how to find out whether a UNIX text file has 'hidden' control characters? Can I view them using 'vi' by some command line options? If there are control characters in a text file which are invisible/hidden.. then how do I get rid of them? Your intelletual answers are... (6 Replies)
Discussion started by: kewl_guy
6 Replies

5. Shell Programming and Scripting

display all possible control characters from .xml file in unix

Hi, I have a .xml file in unix. We are passing this file through a xml parser. But we are getting some control characters from input file and XML parser is failing for the control character in file.Now I am getting following error, Error at byte 243206625 of file filename_$.xml: Error... (1 Reply)
Discussion started by: fantushmayu
1 Replies

6. Shell Programming and Scripting

How to remove Ctlr-M characters from file from a unix script

There are 10 files present which have Ctlr-M characters appended to each line of all files. I have a unix script which processes the files in a loop. And there is an inner loop which processes each line in the file concerned. #inputFile is a variable which has the file name of the input... (2 Replies)
Discussion started by: akashtcs
2 Replies

7. Shell Programming and Scripting

Extra control characters being added when I create a file using cat command

Hi, I am using Cygwin.I created a new file and type into it using cat > newfile. When I open this using vi editor, it contains loads of extra control characters. Whats happening? (1 Reply)
Discussion started by: erora
1 Replies

8. UNIX for Dummies Questions & Answers

Control characters in UNIX

Hi, My files are showing some control characters in vi editor ^M ^@ and somtimes ^H I removed ^M with %s/^M//g command but how to represent ^@ and ^H e.g. for ^M it is hold ctrl then v and m.. Please help.. I am very new to unix.. (7 Replies)
Discussion started by: prabhat.diwaker
7 Replies

9. Shell Programming and Scripting

How to view the control characters in a file?

Hello, How can I view control and special characters of a text file?. For example, space, tabs, new line chars etc. Can I use hexdump for it? Thanks (3 Replies)
Discussion started by: reddyr
3 Replies

10. Red Hat

Special control characters in file

Hi Guys, We receive some huge files on to Linux server. Source system use FTP mechanism to transfer these files on our server. Occasionally one record is getting corrupted while transfer, some control characters are injecting into the file. How to fix this issue ? please advice ? Sample... (2 Replies)
Discussion started by: srikanth38
2 Replies
NEWSGROUPS(5)						    InterNetNews Documentation						     NEWSGROUPS(5)

NAME
newsgroups - List of newsgroups and their short descriptions DESCRIPTION
The file pathdb/newsgroups contains a list of newsgroups for which a short description is available. This file is generally updated by controlchan(8) whenever a control message is received; it is used by nnrpd in response to LIST NEWSGROUPS and is only meant to provide information to users. News readers often show the list of carried newsgroups along with these descriptions. It is not necessary that all the groups carried by the news server (that is to say all the groups listed in the active file) be listed in the newsgroups file. And it is also not necessary that all the groups listed in the newsgroups file be carried by the news server. Nonetheless, it is of course better if the active and newsgroups files have exactly the same newsgroups. If you use "ctlinnd newgroup" to manually create a group, only the active file is updated. You should then edit the newsgroups file in order to add a short description for the created group. The same goes for manually removing or changing the status of a newsgroup. Each line of the newsgroups file consists of two fields separated by at least one tabulation: <name> <description> The first field is the name of the newsgroup. The second field is its description. You can get the newsgroups file of another NNTP server with getlist(1). PREFERRED FORMAT FOR A ONE-LINE NEWSGROUP DESCRIPTION As far as the format of the newsgroups file is concerned, there is a preferred format for each line. Since news administrators do not generally have the time to fix up the lines that are being automatically included from newgroup or checkgroups messages, this information is provided so that control message senders can craft better control messages. It will also be useful for news administrators to know how to format the description of their local newsgroups. There should be at least one hard tab (8 column tab stops) between the group name and the description. If the group name is at least 16 characters, it should be followed with one tab. If the group name is at least 8 characters, it should be followed with two tabs. And in the unlikely event the group name is less than 8 characters, it should be followed with three tabs. For instance: misc.transport.rail.europe Railroads & railways in all of Europe. news.admin.nocem NoCeM protocol policy issues and information. news.groups Discussions and lists of newsgroups. The total line length should be at most 79 columns. The description should start with a capital and not be more than 55 characters (79 - 24) long. If the group name is longer than 24 characters, the description should be correspondingly shorter. If the group is moderated, it should have " (Moderated)" (note the space before the opening parenthesis) at the very end of the description, not counted as part of the length of the description. This text must be exactly that, with no variations, as it is used by news software to find moderated groups. Here is an example of moderated newsgroup: news.lists.misc News-related statistics and lists. (Moderated) Traditionally, all newsgroup descriptions ended with a period, but this is not necessary and steals away one character that is occasionally useful for forming a better description. Some over-long descriptions could be made to easily fit the length by dropping useless wordings like "Discussion of" which do not meaningfully contribute to the description. Others are usually pretty easy to get to no more than column eighty, except when the group names start getting really long. Hopefully then the group name itself contains quite a bit of description. In some cases, a longer description really will be necessary; they can of course be used within the newsgroups file. However, they will probably be less readable and less useful for some Usenet users. Descriptions must not contain any control characters (octets between 0x00 and 0x1F). ENCODING OF THE DESCRIPTIONS
There is, at present, no good mechanism for managing the character set of the newsgroup descriptions. Many non-English hierarchies include newsgroup descriptions in their native languages, since this is more useful for their users, and those are included verbatim in the newsgroups file. This unfortunately means that different lines of the file will require different character set settings to read properly, and those character sets are not documented in the file. Hopefully some future standard will provide a way to address this; in the meantime, using UTF-8 for non-ASCII characters is recommended. MINIMAL NEWSGROUPS FILE
The minimal newsgroups file shipped with INN is: control Various control messages (no posting). control.cancel Cancel messages (no posting). control.checkgroups Hierarchy check control messages (no posting). control.newgroup Newsgroup creation control messages (no posting). control.rmgroup Newsgroup removal control messages (no posting). junk Unfiled articles (no posting). These lines must be tab-delimited, so please be careful in case you copy and paste them from above. HISTORY
Written by Julien Elie for InterNetNews. The preferred format for a one-line newsgroup description is based on the policies by which the newsgroups file in <ftp://ftp.isc.org/pub/usenet/CONFIG/> is maintained; they were originally written by David Lawrence <tale@isc.org> and updated by Russ Allbery <rra@stanford.edu>. $Id: newsgroups.pod 8822 2009-11-20 17:34:15Z iulius $ SEE ALSO
active(5), controlchan(8), ctlinnd(8), getlist(1), nnrpd(8). INN 2.5.3 2010-02-08 NEWSGROUPS(5)
All times are GMT -4. The time now is 01:05 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy