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
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
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
2. UNIX for Dummies Questions & Answers
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
3. UNIX for Dummies Questions & Answers
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
4. BSD
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
5. Shell Programming and Scripting
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
6. Solaris
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
7. UNIX for Advanced & Expert Users
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
8. UNIX Desktop Questions & Answers
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
9. Shell Programming and Scripting
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
10. Debian
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
TR(1) User Commands TR(1)
NAME
tr - translate or delete characters
SYNOPSIS
tr [OPTION]... SET1 [SET2]
DESCRIPTION
Translate, squeeze, and/or delete characters from standard input, writing to standard output.
-c, -C, --complement
use the complement of SET1
-d, --delete
delete characters in SET1, do not translate
-s, --squeeze-repeats
replace each input sequence of a repeated character that is listed in SET1 with a single occurrence of that character
-t, --truncate-set1
first truncate SET1 to length of SET2
--help display this help and exit
--version
output version information and exit
SETs are specified as strings of characters. Most represent themselves. Interpreted sequences are:
NNN character with octal value NNN (1 to 3 octal digits)
\ backslash
a audible BEL
backspace
f form feed
new line
return
horizontal tab
v vertical tab
CHAR1-CHAR2
all characters from CHAR1 to CHAR2 in ascending order
[CHAR*]
in SET2, copies of CHAR until length of SET1
[CHAR*REPEAT]
REPEAT copies of CHAR, REPEAT octal if starting with 0
[:alnum:]
all letters and digits
[:alpha:]
all letters
[:blank:]
all horizontal whitespace
[:cntrl:]
all control characters
[:digit:]
all digits
[:graph:]
all printable characters, not including space
[:lower:]
all lower case letters
[:print:]
all printable characters, including space
[:punct:]
all punctuation characters
[:space:]
all horizontal or vertical whitespace
[:upper:]
all upper case letters
[:xdigit:]
all hexadecimal digits
[=CHAR=]
all characters which are equivalent to CHAR
Translation occurs if -d is not given and both SET1 and SET2 appear. -t may be used only when translating. SET2 is extended to length of
SET1 by repeating its last character as necessary. Excess characters of SET2 are ignored. Only [:lower:] and [:upper:] are guaranteed to
expand in ascending order; used in SET2 while translating, they may only be used in pairs to specify case conversion. -s uses SET1 if not
translating nor deleting; else squeezing uses SET2 and occurs after translation or deletion.
GNU coreutils online help: <http://www.gnu.org/software/coreutils/> Report tr translation bugs to <http://translationproject.org/team/>
AUTHOR
Written by Jim Meyering.
COPYRIGHT
Copyright (C) 2013 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.
SEE ALSO
The full documentation for tr is maintained as a Texinfo manual. If the info and tr programs are properly installed at your site, the com-
mand
info coreutils 'tr invocation'
should give you access to the complete manual.
GNU coreutils 8.22 June 2014 TR(1)