TR squeeze oddity


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers TR squeeze oddity
# 1  
Old 05-02-2008
TR squeeze oddity

I discovered that where 'tr -s' works as expected on grepped input, it appears to completely fail on dig results.

I am not sure if this is because of some sort of non posix compliancy, or what.

Here is what I did:
The command below works as expected, squeezing all repeated spaces to a single space:
ps -ef | grep mc | tr -s \ | cut -d\ -f2,8-9

When i try this on dig, it fails absolutely, as do all possible variances of squeeze in regards to whitespace I could figure out:
dig subkeys.pgp.net | tr -s \
dig subkeys.pgp.net | tr -s \040
dig subkeys.pgp.net | tr -s "040"
dig subkeys.pgp.net | tr -s [:blank:]
dig subkeys.pgp.net | tr -s [:space:]
dig subkeys.pgp.net | tr -s '[:space:]'
(none of the above squeeze any type of whitespace that I could tell)

I ended up doing this,. which has the desired effect:
dig subkeys.pgp.net | tr -t [:space:] \ | cut -d \ -f5

Can anyone explain why squeeze doesn't seem to work on dig results?

Thanks for any help. I appreciate the education.

Bruce D. Meyer
# 2  
Old 05-02-2008
trussed it and had a look :-)

appears to be tab seperated..

have a look at

Code:
dig subkeys.pgp.net | grep "\t"
    and/or
dig subkeys.pgp.net | tr -s "\t" " "

HTH
# 3  
Old 05-03-2008
You can use POSIX character classes instead of ' ' or '\t' == '[:space:]'
# 4  
Old 05-03-2008
Bug Thanks Guys!

Both replies are great. I suspect this will work for other similar situations.

--Bruce D. Meyer Smilie
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Debian

VPN service fails after update applied in Debian Squeeze

Hello everybody, I used to log in to my office via PPTP VPN, but on last October 5th I updated my installed Debian Squeeze and it caused my VPN service (client-side) to fail. After this upgrade I'm unable to log in to the VPN server. Here follows the log: #tail -f /var/log/messages Plugin... (0 Replies)
Discussion started by: r4ym4r
0 Replies

2. Shell Programming and Scripting

Help me please: UNIX command to extract substring not squeeze spaces

Hi experts, Please help me!... I have a string " test1 test2 test3 ". There are two spaces before "test1"; There are four spaces between "test1" and "test2"; there are two spaces between "test2 and "test3". I want to extract a substring "2 test3" using positions. Below is my test... (5 Replies)
Discussion started by: sophiez16
5 Replies

3. UNIX Desktop Questions & Answers

How to squeeze multiple pipe character '|' into single '|' using sed?

Hi, I am trying to convert multiple Unix pipe symbol or bar into single |. I have tried with the following sed statements, but, no success :(. I need it using sed only echo "sed 's/\|\+/\|/g' sed 's/*/\|/' sed 's/\|*/|/' sed -r 's/\|+/\|/' However, the below awk code is working fine.... (4 Replies)
Discussion started by: royalibrahim
4 Replies

4. UNIX for Advanced & Expert Users

Load average in squeeze too low

sorry, not yelling, its just copied from a bug report and this prob is driving me crazy... ran stress --cpu 4 on a xeon and no problem the load went up to 4, but running mysql server for example the load is almost 0.00, where the same mysql server with same throughput gets 0.8 on another lenny... (15 Replies)
Discussion started by: suffeks
15 Replies

5. Solaris

Sort Oddity

All, I'm baffled by some sort behavior on SunOS 5.10 and looking for guidance. Running the command: sort -t'|' -k5,5 -k7,7 -k1,1 -k2,2 -k3,3 -k6,6 -k8,8 test Against the file "test": thirdA||||first||second|Data thirdB||||first||second| thirdC||||first||second|Data... (11 Replies)
Discussion started by: effigy
11 Replies

6. Shell Programming and Scripting

squeeze duplicates from a table

I have files with an x amounts of rows with each row having 2 columns seperated by delimiter "|" . File contains following records for example. 15|69 15|70 15|71 15|72 15|73 15|74 16|2 16|3 16|4 16|5 16|6 16|7 16|8 16|9 16|10 16|11 16|12 (4 Replies)
Discussion started by: Alex_P
4 Replies

7. BSD

Cron Oddity

Our webserver is running FreeBSD, for the last few days we have been having an issue with our cronjobs/mysql server. Specifically we have jobs that execute php scripts to do various things to the website. When running these php scripts manually, via external browser, or lynx on the server, they... (8 Replies)
Discussion started by: mrfr0g
8 Replies

8. UNIX for Dummies Questions & Answers

VSFTP oddity

I am using smartFTP client on my windows machine to connect to a linux box of mine (different location) to download some large files 100+meg. The linux box is running vsftp. After several minutes of downloading, the connection suddenly dies, and I cannot reconnect to the box via FTP using ANY... (7 Replies)
Discussion started by: Spetnik
7 Replies

9. UNIX for Dummies Questions & Answers

Su Password Oddity

Hello Forum, I am having an odd occurence. When i do a su in a terminal or console session, I am able get authenticated as superuser without using the full or correct root password. Anyone have any idea? -AJ (4 Replies)
Discussion started by: jacobsa
4 Replies

10. UNIX for Dummies Questions & Answers

Textual oddity

This is my first post!! I really hope this question hasn't been asked a thousand times before(I'll bet it has). Anyway, here it is. I am new to the UNIX world by the way so forgive my ignorance. OK, whenever I write code on my windows machine and then try to port it over to UNIX I always get... (3 Replies)
Discussion started by: Jubba
3 Replies
Login or Register to Ask a Question