Sponsored Content
Top Forums Shell Programming and Scripting Need help with eliminating newlines with Perl Post 302596403 by brianjb on Tuesday 7th of February 2012 09:34:51 AM
Old 02-07-2012
Need help with eliminating newlines with Perl

Good morning,

I need some help with getting rid of newlines with the output from a MYSQL query and putting the information into the right format that I need.

Here is the script as it is today:

#!/usr/bin/perl

my $uda = system("/opt/incontrol/mysql/bin/mysql -u root -ppassword --skip-column-names instancename -e \"select blah, blah from blahblah;\"");

chomp($uda);


This is the output:

+-----------------+-----------------------------+
| blockTechPhone | 312-555-1212 |
| blockTechName | This guy |
| blockAdminName | hat guy |
| blockAdminPhone | 312-555-3232 |
| blockTechEmail | me@you.com |
| block_name | this is a test|
| subnet_nets | off |
| blockSecName | gfsdg |
+-----------------+-----------------------------+

Note that the output is 10 lines long. I want to get rid of the first and the last line, since those are just clutter from the MYSQL output. Get rid of the "+-----------------+-----------------------------+" lines. I want the rest to be merged into one line like this:


-c uda,set -Tipv4_subnet -a 10.1.10.0 -o Personal -u username -p password --uda Subnet/blockTechPhone="312-555-1212" --uda Subnet/blockTechName="This guy" --uda Subnet/blockAdminName="hat guy" --uda Subnet/blockAdminPhone="312-555-3232" --uda Subnet/blockTechEmail="me@you.com" --uda Subnet/block_name="this is a test" --uda Subnet/subnet_nets="off" --uda Subnet/blockSecName="gfsdg"


What is the best way to get the output into one line I am trying and to insert the additional words that I want like I am describing. I appreciate any assistance!

I am fairly new to Perl, but have a lot of shell scripting experience. I am trying to do this in Perl.
 

10 More Discussions You Might Find Interesting

1. HP-UX

Eliminating characters between two expressions

Hi I have to eliminate all characters between ^ and a space in a file. Following lines - Test ^ H^@^@^@^@^@^@^B^VDM-BM-$|M-^_M-F^AM- File1 Test^H^@^@^@^@^@^F^A^X^@^SM-s^TM-3M-G^A File2 Should be printed as below Test File1 Test File2 I used sed '/^/,/ /d' command, but it is not working.... (1 Reply)
Discussion started by: arsheshadri
1 Replies

2. UNIX for Dummies Questions & Answers

Eliminating CR (new lines) from a file.

Hi all, I made a C++ program in dos (in dev-C++) and uploaded it on Solaris box. On opening that file with 'vim' editor i found that there is some extra new lines after each written code line. I tried to find out is the file is in dos or in unix format, with 'file' command,and i got "<file-name>.h:... (4 Replies)
Discussion started by: KornFire
4 Replies

3. Shell Programming and Scripting

Eliminating output?

Hi Folks, I am writting a shell script for general purpose use.... i have created a function like below:- largest_file() { clear tput cup 20 30 echo please enter the full directory path where you want to search:- tput cup 21 30 read lr_choice1 tput cup 22 30 echo please... (3 Replies)
Discussion started by: rpraharaj84
3 Replies

4. Shell Programming and Scripting

After eliminating then save as a string

Hello, I am using HP-UX B.11.23 U ia64 2591592275 unlimited-user license I am trying to write a sh script on my own system to pass string of word as one parameter The format of the string will be the same But the content after : will be changed each time If you manage to have this as $*... (7 Replies)
Discussion started by: fahad.m
7 Replies

5. Programming

Eliminating a row from a file....

I have a file like 1 0 2 0 3 1 3 0 4 0 6 1 6 0 . . . . . . i need to eliminate values 3 0 and 6 0 in the same way there are such values in the whole file....but 3 1 and 6 1 shuld be present... (2 Replies)
Discussion started by: kamuju
2 Replies

6. Shell Programming and Scripting

perl regexp: no match across newlines

Hi. Here's a tricky one (at least to me): I have a file named theFile.txt (UTF-8) that contains the following: a b cWhen I execute perl -pe 's|a.*c|d|sg' theFile.txtin bash 3.2 on MAC OS X 10.6, I get no match, i.e. the result is a b cagain. Any clues why? (2 Replies)
Discussion started by: BatManWSL
2 Replies

7. Shell Programming and Scripting

Eliminating differences in two files

Hello, I'm having trouble to read two txt files, they have employee records line by line, I need to do the reading of a file that is old and compare it with the new base in the new file, deleting the lines in old file, then add the new file data from the old file and write to the database manager.... (5 Replies)
Discussion started by: selmar
5 Replies

8. Shell Programming and Scripting

Perl, sorting and eliminating duplicates

Hi guys! I'm trying to eliminate some duplicates from a file but I'm like this :wall: !!! My file looks like this: ID_1 0.02 ID_2 2.4e-2 ID_2 4.3.e-9 ID_3 0.003 ID_4 0.2 ID_4 0.05 ID_5 1.2e-3 What I need is to eliminate all the duplicates considering the first column (in this... (6 Replies)
Discussion started by: gabrysfe
6 Replies

9. Shell Programming and Scripting

First zero is eliminating in the awk command

I am using something like this in my code nawk 'BEGIN{OFS=FS="|"} {$15='$CalaMig'} {print}' filename actually value of $CalaMig=01234 But its replacing as 1234 in the 15th postion.Its not taking the first zero. can some one help here (1 Reply)
Discussion started by: saj
1 Replies

10. Shell Programming and Scripting

Eliminating duplicate lines

Hello, I am trying to eliminate lines where column #1 is duplicated. If it is a duplicate, the line with the greater value in column #2 should be deleted: file.dat 123 45.34 345 67.22 949 36.55 123 94.23 888 22.33 345 32.56 Desired ouput 123 45.34 949 36.55 888 22.33 345 32.56... (4 Replies)
Discussion started by: palex
4 Replies
TSI(5)								File Formats Manual							    TSI(5)

NAME
tsi - Transmission Subscriber Identification (TSI) access control list DESCRIPTION
The HylaFAX configuration parameter QualifyTSI specifies whether or not the identity of a calling facsimile machine should be checked against an access control list before receiving facsimile. If QualifyTSI is non-null, then only messages from facsimile machines identi- fied in the file specified by the string (typically etc/tsi) will be accepted. Patterns are specified one per line and must conform to the regular expressions syntax specified by POSIX 1003.2; see re_format(7). Com- ments may be included; they are introduced with the ``#'' character and extend to the end of the line. Any trailing white space on a line is ignored (for convenience when comments are used). If a line begins with ``!'', then the regular expression identifies clients that should be rejected; otherwise regular expressions identify clients whose transmissions should be accepted. The order of patterns in a TSI file is important. When a facsimile is to be received, the fax server will compare the client's TSI against the patterns in the access control list in the order in which they appear in the file. The first pattern that matches the client TSI is used to decide whether to accept or reject the facsimile. If no patterns match the client TSI then the facsimile is rejected. Thus if you want to accept all but a restricted set of TSI the last line in the file should be ``^.*$''. Note that regular expression patterns should be written to match a TSI exactly. That is, patterns should be of the form: ^<pattern>$ where the ``^'' and ``$'' characters are used to specify the start and end of the matching TSI. Additionally, regular expression patterns should handle white space that may appear in known locations. For example, ^([+]1){1}[ .-]*415[ .-]*555[ .-]*1212.*$ matches the following TSI strings: +1.415.555.1212 415 555 1212 1-415-555-1212 Finally, note that regular expressions can be used to specify many TSI with one pattern. NOTES
It would be nice if TSI that were to be matched against were placed in some canonical form (e.g. remove white space and white space-like characters). This is, however, problematic, because some facsimile machines permit any printable ASCII string to be sent as a TSI. SEE ALSO
faxgetty(8), re_format(7), hylafax-config(5) December 5, 1994 TSI(5)
All times are GMT -4. The time now is 02:11 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy