Sponsored Content
Top Forums UNIX for Beginners Questions & Answers Tip to remove line endings and spaces on a pre-formatted text file? Post 303041486 by newbie_01 on Monday 25th of November 2019 03:24:33 PM
Old 11-25-2019
Tip to remove line endings and spaces on a pre-formatted text file?

Hi,

At the moment, using Notepad++ to do a search and replace, manually section by section which is real painful. Yeah, so copying each section of the line of text and putting into a file and then search and replace, need at least 3-operations in Notepad++.

Here's hoping I will be able to get some help on how to do this via some script or sed/awk combination maybe?

Basically, I have an Oracle tnsnames,.ora file that contains several section of text like below. So, there will be lots of the following, I just listed two of them at the moment.

Code:
test123.abcde.com.ny =
 (DESCRIPTION=
   (LOAD_BALANCE=off)(CONNECT_TIMEOUT=10)(TRANSPORT_CONNECT_TIMEOUT=6)
   (ADDRESS_LIST=(LOAD_BALANCE=on)(ADDRESS=(PROTOCOL=TCP)(HOST=abcq1-scan1.abcde.com.ny)(PORT=1521)))
   (ADDRESS_LIST=(LOAD_BALANCE=on)(ADDRESS=(PROTOCOL=TCP)(HOST=abcq1-scan2.abcde.com.ny)(PORT=1521)))
   (ADDRESS_LIST=(LOAD_BALANCE=on)(ADDRESS=(PROTOCOL=TCP)(HOST=abcq1-scan1-dca.abcde.com.ny)(PORT=1521)))
   (ADDRESS_LIST=(LOAD_BALANCE=on)(ADDRESS=(PROTOCOL=TCP)(HOST=abcq1-scan1-dcb.abcde.com.ny)(PORT=1521)))
   (CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=abcq1_app.abcde.com.ny))
 )
test124.abcde.com.ny =
 (DESCRIPTION=
   (LOAD_BALANCE=off)(CONNECT_TIMEOUT=10)(TRANSPORT_CONNECT_TIMEOUT=6)
   (ADDRESS_LIST=(LOAD_BALANCE=on)(ADDRESS=(PROTOCOL=TCP)(HOST=abcq1-scan1.abcde.com.ny)(PORT=1521)))
   (ADDRESS_LIST=(LOAD_BALANCE=on)(ADDRESS=(PROTOCOL=TCP)(HOST=abcq1-scan2.abcde.com.ny)(PORT=1521)))
   (ADDRESS_LIST=(LOAD_BALANCE=on)(ADDRESS=(PROTOCOL=TCP)(HOST=abcq1-scan1-dca.abcde.com.ny)(PORT=1521)))
   (ADDRESS_LIST=(LOAD_BALANCE=on)(ADDRESS=(PROTOCOL=TCP)(HOST=abcq1-scan1-dcb.abcde.com.ny)(PORT=1521)))
   (CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=abcq1_app.abcde.com.ny))
 )

I need to convert it to so that it rids itself of the spaces and line endings so that it now looks as below:


Code:
test123.abcde.com.ny =
(DESCRIPTION=(LOAD_BALANCE=off)(CONNECT_TIMEOUT=10)(TRANSPORT_CONNECT_TIMEOUT=6)(ADDRESS_LIST=(LOAD_BALANCE=on)(ADDRESS=(PROTOCOL=TCP)(HOST=abcq1-scan1.abcde.com.ny)(PORT=1521)))(ADDRESS_LIST=(LOAD_BALANCE=on)(ADDRESS=(PROTOCOL=TCP)(HOST=abcq1-scan2.abcde.com.ny)(PORT=1521)))(ADDRESS_LIST=(LOAD_BALANCE=on)(ADDRESS=(PROTOCOL=TCP)(HOST=abcq1-scan1-dca.abcde.com.ny)(PORT=1521)))(ADDRESS_LIST=(LOAD_BALANCE=on)(ADDRESS=(PROTOCOL=TCP)(HOST=abcq1-scan1-dcb.abcde.com.ny)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=abcq1_app.abcde.com.ny)))
test124.abcde.com.ny =
(DESCRIPTION=(LOAD_BALANCE=off)(CONNECT_TIMEOUT=10)(TRANSPORT_CONNECT_TIMEOUT=6)(ADDRESS_LIST=(LOAD_BALANCE=on)(ADDRESS=(PROTOCOL=TCP)(HOST=abcq1-scan1.abcde.com.ny)(PORT=1521)))(ADDRESS_LIST=(LOAD_BALANCE=on)(ADDRESS=(PROTOCOL=TCP)(HOST=abcq1-scan2.abcde.com.ny)(PORT=1521)))(ADDRESS_LIST=(LOAD_BALANCE=on)(ADDRESS=(PROTOCOL=TCP)(HOST=abcq1-scan1-dca.abcde.com.ny)(PORT=1521)))(ADDRESS_LIST=(LOAD_BALANCE=on)(ADDRESS=(PROTOCOL=TCP)(HOST=abcq1-scan1-dcb.abcde.com.ny)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=abcq1_app.abcde.com.ny)))

Please advise. Thanks.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

How to remove FIRST Line of huge text file on Solaris

i need help..!!!! i have one big text file estimate data file size 50 - 100GB with 70 Mega Rows. on OS SUN Solaris version 8 How i can remove first line of the text file. Please suggest me for solutions. Thank you very much in advance:) (5 Replies)
Discussion started by: madoatz
5 Replies

2. Shell Programming and Scripting

Adding specific text and spaces to each line in a text file

Hi, I wanted to add specific text to each row in a text file containing three rows. Example: 0 8 7 6 5 5 7 8 9 0 7 9 7 8 9 0 1 2 And I want to add a 21 at the beginning of the first row, and blank spaces at the beginning of the second two rows. To get this: 21 0 8 7 6 5 5 7 8... (4 Replies)
Discussion started by: hertingm
4 Replies

3. Shell Programming and Scripting

Remove spaces from first field, and write entire contents into other text file

Hi all, I have searched and found various threads about removing spaces from a field within a text file. Unfortunately, I have not found exactly what I'm looking for, nor am I adept enough to modify what I've found into what I need. I use the following command to remove the first line... (3 Replies)
Discussion started by: carriehoff
3 Replies

4. Shell Programming and Scripting

Remove blank spaces in a text file...

Hi, I have this problem that there are blank spaces in my text file... i want to remove them line 1 line 2 line 3 I want to remove the space between line 2 and line 3... I tried sed... it work but it prints the whole text file at the command prompt which i dont want.... sde i tried was... (4 Replies)
Discussion started by: bhagya2340
4 Replies

5. Shell Programming and Scripting

Need to remove improperly formatted fortran output line from files, tried sed

I have been trying to remove some improperly formatted lines of output from fortran code I have been using. The problem is that I have some singularities in the math for some points that causes an incorrectly large value to be reported that exceeds the normal formating set in the code resulting in... (2 Replies)
Discussion started by: gillesc_mac
2 Replies

6. Shell Programming and Scripting

sed to remove 1st two characters every line of text file

what is the sed command to remove the first two characters of every line of a text file? each line of the text file has the same amount of characters, and they are ALL NUMERIC. there are hundreds of lines though. for example, >cat file1.txt 10081551 10081599 10082234 10082259 20081134... (20 Replies)
Discussion started by: ajp7701
20 Replies

7. Shell Programming and Scripting

How to remove blank line from a text file?

Hi All, I am creating a text file using perl. The first record I am writing as "$line" and all the other as "\n$line". At the end the file is having N number of lines. I am using this file for MLOAD (Teradata), which is reading N+1 lines in the file and failing.I am not able to find new line... (2 Replies)
Discussion started by: unankix
2 Replies

8. Shell Programming and Scripting

How Select numbers from a line of text, and remove leading spaces?

I have a text file with a line of text that contains numbers and text formatted into groups. I need to extract the number that can be either 1,2 or 3 digits long. Then write it to a variable, but i need to remove any leading spaces in the number first. I can get the numbers out but how to remove... (12 Replies)
Discussion started by: kcpoole
12 Replies

9. UNIX Desktop Questions & Answers

To remove the extra spaces at the end of each line in a file

I have a file of about 10k records and eace line is having an extra space of 5 byte at the end.. Iwant to remove the extra spaces at the end of each line.. Can someone please help me out.. I tried using sed command and its not working... can someone please help me out. (3 Replies)
Discussion started by: rammohan
3 Replies

10. Shell Programming and Scripting

How to remove spaces on a line?

Hi, suppose I have the following data: albert music=top40 age=20 bob music=punk rock age=25 candy music=r n b age=22 dave music=mozart or bach only age=30 I want to extract and manipulate the music column but it's got spaces in it. How can I substitute the space with an underscore... (2 Replies)
Discussion started by: almonds
2 Replies
htdig(1)						      General Commands Manual							  htdig(1)

NAME
htfuzzy - fuzzy command-line search utility for the ht://Dig search engine SYNOPSIS
htfuzzy [-c configfile] [-v] algorithm [options] DESCRIPTION
Description to follow here OPTIONS
-c configfile Use the specified configfile instead of the default. -v Verbose mode , -vvv etc ). Specifying more than two v's is probably only useful for debugging purposes. Supported Algorithms Different algoritms are supported for searching: soundex Creates a slightly modified soundex key database. Differences with the standard soundex algorithm are: Keys are 6 digits and the first letter is also encoded. metaphone Creates a metaphone key database. This algorithm is more specific to English, but will get fewer "weird" matches than the soundex algorithm. accents (No description of the algorithm at the moment) endings Creates two databases which can be used to match common word endings. The creation of these databases requires a list of affix rules and a dictionary which uses those affix rules. The format of the affix rules and dictionary files are the ones used by the ispell program. Included with the distribution are the affix rules for English and a fairly small English dictionary. Other languages can be supported by getting the appropriate affix rules and dictionaries. These are available for many languages; check the ispell distribu- tion for more details. synonyms Creates a database of synonyms for words. It reads a text database of synonyms and creates a database that htsearch can then use. Each line of the text database consists of words where the first word will have the other words on that line as synonyms. Notes on searching Please consult specialised literature to find out how the different algorithms work or simply try another search stragegy you do not get the intended search results. FILES
/etc/htdig/htdig.conf The default configuration file. /var/lib/htdig/db/db.accents.db (Output) Maps between characters with and without accents for accents fuzzy rule /var/lib/htdig/db/db.metaphone.db (Output) Database of similar-sounding words for metaphone fuzzy rule /var/lib/htdig/db/db.soundex.db (Output) Database of similar-sounding words for soundex fuzzy rule /srv/www/htdig/common/english.0, /srv/www/htdig/common/english.aff (Input) List of words and affix rules used to generate endings /srv/www/htdig/common/root2word.db, /srv/www/htdig/common/word2rood.db (Output) Database used for endings fuzzy rule /srv/www/htdig/common/synonyms (Input) List of groups of words considered synonymous /srv/www/htdig/common/synonyms.db (Output) Database used for synonyms fuzzy rule SEE ALSO
Please refer to the HTML pages (in the htdig-doc package) /usr/share/doc/htdig-doc/html/index.html and the manual pages htdigconfig(8) , htmerge(1) , htnotify(1) , htsearch(1) and rundig(1) for a detailed description of ht://Dig and its commands. AUTHOR
This manual page was written by Robert Ribnitz. It is based on documentation of ht://Dig, and on earlier manpages provided by Christian Schwarz and Stijn de Bekker. 21 July 1997 htdig(1)
All times are GMT -4. The time now is 01:52 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy