Sponsored Content
Top Forums Shell Programming and Scripting Removal of extra spaces in *.log files to allow extraction of frequencies Post 302797075 by hanson44 on Sunday 21st of April 2013 09:40:14 PM
Old 04-21-2013
You can put these two lines in any shell script, and it will correct the formatting:
Code:
$ cat atoms.sh
sed -e "s/ Atom  AN/Atom AN/" -e "s/^     /   /" atoms.txt > /tmp/temp.x
mv /tmp/temp.x atoms.txt

I changed the first substitution a little to ensure that the correction is only applied once. So if the log file gets corrected once, and then new text is appended to the end, the previously corrected section will not get "corrected again".

Are you sure there are no other lines that start with five blanks? As the script is right now, any line that starts with five blanks will be switched to start with three blanks.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

To remove the extra spaces in unix

Hi... I am quite new to Unix and would like an issue to be resolved. I have a file in the format below; 4,Reclaim,ECXTEST02,abc123,Harry Potter,5432 6730 0327 5469,0603,,MC,,1200,EUR,sho-001,,1,,,abc123,1223 I would like my output to be as follows; 4,Reclaim,ECXTEST02,abc123,Harry... (4 Replies)
Discussion started by: Sho
4 Replies

2. Shell Programming and Scripting

How to remove extra spaces from a string??

Hi, I have a string like this and i want to remove extra spaces that exists between the words. Here is the sentence. $string="The small DNA genome of hepadnaviruses is replicated by reverse transcription via an RNA intermediate. This RNA "pregenome" contains ... (2 Replies)
Discussion started by: vanitham
2 Replies

3. UNIX for Dummies Questions & Answers

selective removal of blank spaces in string

Hi, I'm a newbie to shell scripting and I have the following problem: I need all spaces between two letters or a letter and a number exchanged for an underscore, but all spaces between a letter and other characters need to remain. Searching forums didn't help... One example for clarity: ... (3 Replies)
Discussion started by: Cpt_Cell
3 Replies

4. Shell Programming and Scripting

Help with removal of blank spaces in a file

Hello.. I have a text file. I want to remove all the blank spaces(except tab) from the file.. I tried using sed command as shown below sed 's/ //g' file1 But the problem with the above command is that it also eliminates 'tab' which is between the columns.. For example if the contents... (7 Replies)
Discussion started by: abk07
7 Replies

5. Shell Programming and Scripting

Help with removal of blank spaces from the second field!

Hi everyone.. I'm trying to eliminate multiple whitespaces from a file.. I must make use of shell script to eliminate whitespaces.. Take a look at the sample file 1 int main() 2 { 3 int a,b; 4 printf("Enter the values of a and b"); 5 scanf("%d%d",&a,&b); 6 if(a>b) ... (6 Replies)
Discussion started by: abk07
6 Replies

6. Shell Programming and Scripting

Help with removal of spaces between operators and operands

Hi I'm trying to remove blank spaces in expressions and function calls.. Consider the following example printf ("Hello"); a = a + b; I'm trying to eliminate space in between the function name and the opening brace. And also eliminate space between operators and operands.. That is, I'm... (19 Replies)
Discussion started by: abk07
19 Replies

7. Shell Programming and Scripting

Remove of extra spaces from the trailing

HI, I need the help from the experts like I have created one file with text like: a b c d e f g h i j k l So my question is that i have to write the script in which like in the first sentence it will take only one space after d and remove all the extra space in the end.I dont... (8 Replies)
Discussion started by: bhanudhingra
8 Replies

8. Shell Programming and Scripting

What extra Parameters I can use for archiving log files

Hello All, I have developed a script which takes following parameter from the input file to archive log files 1)Input Path 2)File pattern(*.csv) 3)Number of days(+1) Following is the algorithm of my script Read the input file go to that path and search for particular n days older... (3 Replies)
Discussion started by: mitsyjohn
3 Replies

9. Shell Programming and Scripting

Removing extra unwanted spaces

hi, i need to remove the extra spaces in the filed. Sample: abc~bd ~bkd123 .. 1space abc~badf ~bakdsf123 .. 2space abc~bqed ~bakuowe .. 3space output: abc~bd ~bkd123 .. 1space abc~badf~bakdsf123 .. 2space abc~bqed~bakuowe .. 3space i used the following command, (2 Replies)
Discussion started by: anshaa
2 Replies

10. Shell Programming and Scripting

Grep string causes extra spaces

Hello, I have an xml file and my aim is to grab each line in keywords file and search the string in another file. When keyword is found in xml file,I expect the script to go to previous line in the xml file and grab the string/value between two strings. It's almost working with an error. tab... (6 Replies)
Discussion started by: baris35
6 Replies
XInternAtom(3)							  XLIB FUNCTIONS						    XInternAtom(3)

NAME
XInternAtom, XInternAtoms, XGetAtomName, XGetAtomNames - create or return atom names SYNTAX
Atom XInternAtom(Display *display, char *atom_name, Bool only_if_exists); Status XInternAtoms(Display *display, char **names, int count, Bool only_if_exists, Atom *atoms_return); char *XGetAtomName(Display *display, Atom atom); Status XGetAtomNames(Display *display, Atom *atoms, int count, char **names_return); ARGUMENTS
atom Specifies the atom for the property name you want returned. atoms Specifies the array of atoms. atom_name Specifies the name associated with the atom you want returned. atoms_return Returns the atoms. count Specifies the number of atom names in the array. count Specifies the number of atoms in the array. display Specifies the connection to the X server. names Specifies the array of atom names. names_return Returns the atom names. only_if_exists Specifies a Boolean value that indicates whether the atom must be created. DESCRIPTION
The XInternAtom function returns the atom identifier associated with the specified atom_name string. If only_if_exists is False, the atom is created if it does not exist. Therefore, XInternAtom can return None. If the atom name is not in the Host Portable Character Encoding, the result is implementation-dependent. Uppercase and lowercase matter; the strings ``thing'', ``Thing'', and ``thinG'' all designate dif- ferent atoms. The atom will remain defined even after the client's connection closes. It will become undefined only when the last connec- tion to the X server closes. XInternAtom can generate BadAlloc and BadValue errors. The XInternAtoms function returns the atom identifiers associated with the specified names. The atoms are stored in the atoms_return array supplied by the caller. Calling this function is equivalent to calling XInternAtom for each of the names in turn with the specified value of only_if_exists, but this function minimizes the number of round-trip protocol exchanges between the client and the X server. This function returns a nonzero status if atoms are returned for all of the names; otherwise, it returns zero. XInternAtoms can generate BadAlloc and BadValue errors. The XGetAtomName function returns the name associated with the specified atom. If the data returned by the server is in the Latin Portable Character Encoding, then the returned string is in the Host Portable Character Encoding. Otherwise, the result is implementation-depen- dent. To free the resulting string, call XFree. XGetAtomName can generate a BadAtom error. The XGetAtomNames function returns the names associated with the specified atoms. The names are stored in the names_return array supplied by the caller. Calling this function is equivalent to calling XGetAtomName for each of the atoms in turn, but this function minimizes the number of round-trip protocol exchanges between the client and the X server. This function returns a nonzero status if names are returned for all of the atoms; otherwise, it returns zero. XGetAtomNames can generate a BadAtom error. DIAGNOSTICS
BadAlloc The server failed to allocate the requested resource or server memory. BadAtom A value for an Atom argument does not name a defined Atom. BadValue Some numeric value falls outside the range of values accepted by the request. Unless a specific range is specified for an argu- ment, the full range defined by the argument's type is accepted. Any argument defined as a set of alternatives can generate this error. SEE ALSO
XFree(3), XGetWindowProperty(3) Xlib - C Language X Interface X Version 11 libX11 1.3.2 XInternAtom(3)
All times are GMT -4. The time now is 06:59 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy