Handling Unit Seperator Delimeter


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Handling Unit Seperator Delimeter
# 1  
Old 05-06-2008
Handling Unit Seperator Delimeter

Hi,
We have a file with a unit seperator as the delimeter.

Here are the Sample lines from the file:

ASIA/PACIFICHong KongFX2007071080900
ASIA/PACIFICHong KongFX2007071080900/ 800129HK

This delimeter has the ascii value of \037.
I have to strip the second feild in this file for which i m
using the cut command as follows:
lines=`cat ibia.txt | cut -d "" -f2`
and this works for me.

But i just want to confirm if it is the
correct way to proceed or should we try to do the same with Ascii value
or is there any other better means of handling it.

I tried with Ascii value and i get "bad delimeter". Please help.

Thanks in advance,
Sudha.
sviswana
# 2  
Old 05-06-2008
If it works, it's correct. :-)

However you may prefer to make it more readable, perhaps this:

Code:
lines=`awk -F '\037' '{print $2}' ibia.txt`

# 3  
Old 05-08-2008
Thanks a lot. But giving ascii value does'nt work thats y I gave the delimeter directly.
sviswana
# 4  
Old 05-08-2008
It may not work with cut, but it does work with awk, at least for me.
# 5  
Old 06-18-2008
Getting Fractional part in Division

Hi,
I have a simple code as follows:
Percent_fail=`echo "scale=6; $Col_nm_cnt / $Line_cnt_lan" | bc`

Though I get the answer correcly as follows, I also get an error msg along with it as follows:
.333333
./test.ksh[14]: .333333: unexpected `.'

Can anyone please help me how to avoid this error message and why i get this message

Thanks in advance,
Sudha.
sviswana
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Field seperator with awk

Hi, input data format: echo ' <APPLICATION="APPLSG" SUB_APPLICATION="DLY" JOBNAME="DPL_BN_RE_CCMS_SA" CMDLINE="run_job.ksh %%PARAM1 %%PARAM2" TASKTYPE="Command" />' expected format: "APPLSG", "DLY", "DPL_BN_RE_CCMS_SA", "run_job.ksh %%PARAM1 %%PARAM2" my command: echo ' ... (2 Replies)
Discussion started by: JSKOBS
2 Replies

2. Shell Programming and Scripting

Replacing the delimeter with other delimeter

Hi Friends, I have a file1.txt as below 29123973Ç2012-0529Ç35310124Ç000000000004762Ç00010Ç20Ç390ÇÇÇÇF 29123974Ç20120529Ç35310125Ç0000000000046770Ç00010Ç20Ç390ÇÇÇÇF 29123975Ç20120529Ç35310126Ç0000000000046804Ç00010Ç20Ç390ÇÇÇÇF 29123976Ç20120529Ç35310127Ç0000000000044820Ç00010Ç20Ç390ÇÇÇÇF i have a file2.txt... (4 Replies)
Discussion started by: i150371485
4 Replies

3. Shell Programming and Scripting

Count the delimeter from a file and delete the row if delimeter count doesnt match.

I have a file containing about 5 million rows, in the file there are some records which has extra delimiter at random position. (we dont know the positions), now we have to Count the delimeter from each row and if the count of delimeter is not matching then I want to delete those rows from the... (5 Replies)
Discussion started by: Akumar1
5 Replies

4. Shell Programming and Scripting

SUBSEP Seperator problem with awk

The following code removes new line with in double quotes I am replacing newline character with in double quotes with 123. intermediatenewline_remover () { typeset Infile=$1 nawk -F"," '{ record = record $0 if ( gsub( /"/, "&", record ) % 2 ) { record = record "123" ... (3 Replies)
Discussion started by: pinnacle
3 Replies

5. Shell Programming and Scripting

Printing value with no obvious field seperator

Hi all, Can anybody think of a way to do this? I have a file with content like the following: F_TOP_PARAM_VALUEF_TOP_SOURCEF_TOP_DEL_NOTIFICATIONF_DEST_ADDRF_TOP_DEL_TYPE What I want to do is print out the value in the square brackets after F_TOP_SOURCE. So in this case I'd like to print... (4 Replies)
Discussion started by: Donkey25
4 Replies

6. Shell Programming and Scripting

How to change field seperator

Hi Please help me out with this problem: I want to have a script that would change the nth field seperator in a line into something else. like a,d,4,2,97,8,9 into a,d,4,2,97/8/9 Thanks (2 Replies)
Discussion started by: onthetopo
2 Replies

7. UNIX for Dummies Questions & Answers

Using | as a seperator in join

I need to use | as a seperator in unix join command. i tried changing seperator using -t option but iit is not working. can u please help. (5 Replies)
Discussion started by: firvin
5 Replies

8. Shell Programming and Scripting

Comma seperator

I am trying to create a new CSV file from an existing CSV file whose content is as follows: "1","Tom,Garry","111" "2","Tom,Garry","222" when i use Cat file | cut -d',' -f1,3 or awk to have only the 1st and 3rd column in my new CSV file, instead of creating a file content as "1","111"... (6 Replies)
Discussion started by: premar
6 Replies

9. Solaris

how i can use a WORD for seperator

hi, i want to use A WORD for seperator in awk or especially in cut. how i can perform this. is there any way to use a word for seperator. For example: i want to list all word after FROM and the files name contains this word. chatnorollback.svc: delete from info where nick ... (3 Replies)
Discussion started by: qrshat
3 Replies

10. Shell Programming and Scripting

Awk Field Seperator Help

I wrote a script on HPUX 11.11 to turn a Decimal subnet mask (255.255.254.0) to hex 0xfffffe00 (subset of a bigger script). It works great on the HPUX systems but on the freebsd box the awk is not seperating the fields properly. I tried to google for a solution and seaching these forums i am just... (3 Replies)
Discussion started by: insania
3 Replies
Login or Register to Ask a Question