Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Cut with signed value for delimiter 2

Status
Not open for further replies.

stewartdwest

Programmer
Nov 27, 2003
7
US
cut -f 2 -d "," myfile.txt works great to cut the second column from a comma delimited text file.

What would the syntax be for specifying a delimiter with the value x"b8"

cut -f 2 -d x"b8" myfile.txt produces
cut: "invalid delimiter"
 
one way to specify your delimiter is

DELIM=`echo -e \\\270'; cut -f1 -d$DELIM file

but looks like cut does not compare the character properly and hence i get the whole line:

bash-2.05$ cut -f 2 -d $DELIM junk
a¸b¸c¸

so perhaps you can translate this character to some other character (say comma) using tr and then use cut:

bash-2.05$ tr $DELIM , < junk | cut -f2 -d,
b
bash-2.05$
 
Thanks for verifying that the Solaris 8 cut utility does not appear to support signed delimiters.
I need a cut utility that can handle signed delimiters. The delimiter cannot be translated safely to unsigned values without mapping to existing data values. Also, the datasets are >10GB so efficient processing is preferred.
 
Try this:
Code:
DELIM=`echo &quot;\0270&quot;`
cut -f 2 -d &quot;$DELIM&quot; myfile.txt
If you still get an error, then try this:
Code:
awk -F&quot;$DELIM&quot; '{print $2}' myfile.txt

Hope This Help
PH.
 
This works great using cut with signed delimiters:

DELIM=`echo &quot;\0270&quot;`
cut -f 2 -d &quot;$DELIM&quot; myfile.txt

--------------
The awk version is probably ok for smaller field counts,
myfile.txt has 940 fields:

awk -F&quot;$DELIM&quot; '{print $2}' myfile.txt

awk: record `0069244630¸C¸150¸692446...' has too many fields
record number 1
$
thx!
 
what i said did not work on the sun4m (bash) works fine on a linux x86 (bash) without the quotes surrounding $DELIM ...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top