05-18-2010
Quote:
Originally Posted by
alister
Like zaxxon, I also like this approach; clever use of FS and NF.
However, it does have a bug. If the value of $NF is the number zero, !$NF will be true (since $NF is evaluated numerically, instead of as a string), which would be incorrect. The solution would be to use length($NF) or concatenate a null string to force conversion to a string type, $NF"".
Good point!
Regards
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
I'm not very familiar with the ssh command. When I tried to set a variable and then echo its value on a remote machine via ssh, I found a problem. For example,
$ ITSME=itsme
$ ssh xxx.xxxx.xxx.xxx "ITSME=itsyou; echo $ITSME"
itsme
$ ssh xxx.xxxx.xxx.xxx 'ITSME=itsyou; echo $ITSME'
itsyou
$... (3 Replies)
Discussion started by: password636
3 Replies
2. UNIX for Advanced & Expert Users
I want to remove the comma which is present within the double quoted string. All other commas which is present outside double quotes should be present.
Input : a,b,"cc,dd,ee",f,ii,"jj,kk",mmm
output : a,b,"ccddee",f,ii,"jjkk",mmm (3 Replies)
Discussion started by: mohan_tuty
3 Replies
3. Shell Programming and Scripting
Hi Experts,
I have a file with some of the records contain double quotes. If I found a double quote(") in any particular record , I need to look for the next double quote in that particular record and in between these quotes, if any comma(,) is there I need to replace with Tilde (~) in the same... (12 Replies)
Discussion started by: vsairam
12 Replies
4. UNIX for Dummies Questions & Answers
Unix superusers,
I am new to unix but would like to learn more about grep. I am very familiar with regular expressions as i have used them for searching text files in windows based text editors. Since I am not very familiar with Unix, I dont understand when one should use GREP with the... (2 Replies)
Discussion started by: george_vandelet
2 Replies
5. Shell Programming and Scripting
Hi Guys,
I have a file with content as below
aj.txt
"Iam
allfine" abcdef
abcd "all is
not well"
What I'm trying to say is my data has some new line characters in between quoted text. I must get ride of the newline character that comes in between the quoted text.
output must be:... (8 Replies)
Discussion started by: ajahuja
8 Replies
6. UNIX for Dummies Questions & Answers
I have a file and some records may contain double quotes at beginning and at end of line. So how do I strip them?
For Example, file is somethings like this
Field1;Field2;Field3
01;'Test';'Test Field3'
"01;'This is 2nd field';This is 3rd field' "
Desired Output is:
... (6 Replies)
Discussion started by: vx04
6 Replies
7. Shell Programming and Scripting
Hi,
Trying to change the prompt. I have the following code.
export PS1='
<${USER}@`hostname -s`>$ '
The hostname is not displayed
<abc@`hostname -s`>$ uname -a
AIX xyz 1 6 00F736154C00
<adcwl4h@`hostname -s`>$
If I use double quotes, then the hostname is printed properly but... (3 Replies)
Discussion started by: bobbygsk
3 Replies
8. Shell Programming and Scripting
Hi All,
I'm unable to load the data using sql loader where there are double quotes within the double quotes As these are optionally enclosed by double quotes.
Sample Data :
"221100",138.00,"D","0019/1477","44012075","49938","49938/15043000","Television - 22" Refurbished - Airwave","Supply... (6 Replies)
Discussion started by: mlavanya
6 Replies
9. Shell Programming and Scripting
Hi All,
I am getting .csv file whenever there is a comma present between a field that field get enclosed with double quotes
For eg as below
abc,123,xxyy,2178
fgh,123,"x,x"yy",2178
ghi,123,"x,xyy",2178
jkl,123,xx"yy,2178
whereas I want my data as per below
abc,123,xxyy,2178... (1 Reply)
Discussion started by: H_bansal
1 Replies
10. Shell Programming and Scripting
For one of my need I was going through post "Removal of new line character in double quotes"
Which alister has replied like
$ cat data
"leave me alone"
"ABCD RENT-A-
CAR XYZ LTD","00N0H","Enterprise Lake","
100 View Way"
$ sed -n 'H;g;/^*"*\("*"*\)*$/d; s/^\n//; y/\n/ /; p; s/.*//; h'... (9 Replies)
Discussion started by: Jag_1981
9 Replies
LEARN ABOUT OSX
tcl_printdouble
Tcl_PrintDouble(3) Tcl Library Procedures Tcl_PrintDouble(3)
__________________________________________________________________________________________________________________________________________________
NAME
Tcl_PrintDouble - Convert floating value to string
SYNOPSIS
#include <tcl.h>
Tcl_PrintDouble(interp, value, dst)
ARGUMENTS
Tcl_Interp *interp (in) Before Tcl 8.0, the tcl_precision variable in this interpreter controlled the conversion. As of Tcl 8.0,
this argument is ignored and the conversion is controlled by the tcl_precision variable that is now shared
by all interpreters.
double value (in) Floating-point value to be converted.
char *dst (out) Where to store the string representing value. Must have at least TCL_DOUBLE_SPACE characters of storage.
_________________________________________________________________
DESCRIPTION
Tcl_PrintDouble generates a string that represents the value of value and stores it in memory at the location given by dst. It uses %g
format to generate the string, with one special twist: the string is guaranteed to contain either a "." or an "e" so that it does not look
like an integer. Where %g would generate an integer with no decimal point, Tcl_PrintDouble adds ".0". |
If the tcl_precision value is non-zero, the result will have precisely that many digits of significance. If the value is zero (the |
default), the result will have the fewest digits needed to represent the number in such a way that Tcl_NewDoubleObj will generate the same |
number when presented with the given string. IEEE semantics of rounding to even apply to the conversion.
KEYWORDS
conversion, double-precision, floating-point, string
Tcl 8.0 Tcl_PrintDouble(3)