Sponsored Content
Full Discussion: OFS in awk
Top Forums UNIX for Dummies Questions & Answers OFS in awk Post 302720077 by MIA651 on Tuesday 23rd of October 2012 12:58:21 PM
Old 10-23-2012
Yes, sorry I should've done that from the beginning but here is the output:

Code:
head -5 xtr3.rpl

Outputs:

00530083 0000000471 000000000000.00 000000000000.00
00530085 0000000471 000000000000.00 000000000000.00
00550002 0000000471 000000000000.00 000000000015.00
00550030 0000000471 000000000000.00-000000000007.99
00550034 0000000471 000000000000.00 000000000000.00
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

OFS in awk

Hi, I have these out put field seperator changed to "|" in my awk command, but it didn't give me the result. Can someone help me find out why? ======================================= /bin/awk 'BEGIN { OFS="|" } { print $0 }' list.tmp.$$ > listtmp.$$ =======================================... (1 Reply)
Discussion started by: whatsfordinner
1 Replies

2. Shell Programming and Scripting

OFS in awk.

OFS is inbuild command in awk. I have a file file.txt abc : def : ghi jkl : mno: pqr stu : vwx :yzz code i used: awk -F ":" 'BEGIN {OFS="|"} {print $1,$2}' file.txt output: abc def jkl mno stu vwx but as i have used OFS="|" and i am expecting output as: abc | def jkl... (4 Replies)
Discussion started by: salil2012
4 Replies

3. Shell Programming and Scripting

AWK - OFS

Hi All, I have a comma seperated delimited file with 10 columns. I need to convert it into TAB seperated delimited file. awk -F"," '{print $1"\t"$2"\t"$3"\t"$4"\t"$5"\t"$6"\t"$7"\t"$8"\t"$9"\t"$10}' a.txt >> b.txt how to use OFS to get the same output. I have tried by googling, but it... (5 Replies)
Discussion started by: Amit.Sagpariya
5 Replies

4. Shell Programming and Scripting

Parsing XML in awk : OFS does not work as expected

Hi, I am trying to parse regular XML file where I have to reduce number of decimal points in some xml elements. I am using following AWK command to achive that : #!/bin/ksh EDITCMD='BEGIN { FS = ""; OFS=FS } { if ( $3 ~ "*\\.*" && length(substr($3,1+index($3,"."))) == 15 ) {... (4 Replies)
Discussion started by: martin.franek
4 Replies

5. UNIX for Dummies Questions & Answers

Problem with AWK and OFS

I have a file that looks like this: Infile.seq I want to output the DNA sequence and add the filename as the identifier. The output file should look like this: I am using the following code but I do not understand why the sequence is not in the output: awk 'BEGIN { RS =... (11 Replies)
Discussion started by: Xterra
11 Replies

6. Shell Programming and Scripting

Awk OFS issues

Hi Im trying to tidy up the output of a who command when it writes to a log, everything I've tried doesnt seem to work though, any help would be massively appreciated. Im using the awk command to set the OFS as tab. #!/bin/bash who >> /export/home/tjmoore/logusers awk -F 'BEGIN... (3 Replies)
Discussion started by: 02JayJay02
3 Replies

7. Shell Programming and Scripting

Awk OFS issues

Hi, Could anyone tell me what Im doing wrong here any help will be much appreciated #!/bin/bash ls -ltr /export/home/tjmoore > /export/home/tjmoore/log100 awk -F " " /export/home/tjmoore/log100 'BEGIN {OFS="\t";} {print $1,$2,$3,$4,$5, $6,$7,$8,$9;}' > /export/home/tjmoore/log1001 I... (9 Replies)
Discussion started by: 02JayJay02
9 Replies

8. Shell Programming and Scripting

OFS print awk

file: sasa|asasa|asasa|asas erer|Erer|rere|ererer Output needed : sasa:asasa:asasa:asas erer:Erer:rere:ererer Im getting output, when i use the $1,$2. awk -F'|' 'BEGIN{OFS=":";} {print $1,$2; }' file Output : sasa:asasa erer:Erer But when i need the whole column, i... (5 Replies)
Discussion started by: Ramesh M
5 Replies

9. Shell Programming and Scripting

OFS does not apply to few records in awk

Hi , I am having a problem with my awk oneliner , which for some reason leaves the first two records Input File $ cat file1 A1:B1:C1:NoLimit M1:M2:M3:Limit A2:B2:C2,C3,C4,C5 A3:B3:C3,C4,C5,C6,C7Desired output A1,B1,C1,NoLimit M1,M2,M3,Limit A2,B2,C2 ,,,C3 ,,,C4 ,,,C5 A3,B3,C3... (5 Replies)
Discussion started by: chidori
5 Replies

10. Shell Programming and Scripting

awk - OFS printing duplicate. Why?

Why the following code printing duplicate records? bash-4.1$ cat rm1 c1 c2 c3 l1 2 3 4 l2 2 3 2 bash-4.1$ awk '{print $0} OFS = "\n"' rm1 c1 c2 c3 c1 c2 c3 l1 2 3 4 l1 2 3... (4 Replies)
Discussion started by: quincyjones
4 Replies
Bluetooth(3pm)						User Contributed Perl Documentation					    Bluetooth(3pm)

NAME
Net::Bluetooth - Perl Bluetooth Interface SYNOPSIS
use Net::Bluetooth; #### list all remote devices in the area my $device_ref = get_remote_devices(); foreach $addr (keys %$device_ref) { print "Address: $addr Name: $device_ref->{$addr} "; } #### search for a specific service(0x1101) on a remote device my @sdp_array = sdp_search($addr, "1101", ""); #### foreach service record foreach $rec_ref (@sdp_array) { #### Print all available information for service foreach $attr (keys %$rec_ref) { print "Attribute: $attr Value: $rec_ref->{$attr} "; } } #### Create a RFCOMM client $obj = Net::Bluetooth->newsocket("RFCOMM"); die "socket error $! " unless(defined($obj)); if($obj->connect($addr, $port) != 0) { die "connect error: $! "; } #### create a Perl filehandle for reading and writing *SERVER = $obj->perlfh(); $amount = read(SERVER, $buf, 256); close(SERVER); #### create a RFCOMM server $obj = Net::Bluetooth->newsocket("RFCOMM"); #### bind to port 1 if($obj->bind(1) != 0) { die "bind error: $! "; } #### listen with a backlog of 2 if($obj->listen(2) != 0) { die "listen error: $! "; } #### register a service #### $obj must be a open and bound socket my $service_obj = Net::Bluetooth->newservice($obj, "1101", "GPS", "GPS Receiver"); unless(defined($service_obj)) { #### couldn't register service } #### accept a client connection $client_obj = $obj->accept(); unless(defined($client_obj)) { die "client accept failed: $! "; } #### get client information my ($caddr, $port) = $client_obj->getpeername(); #### create a Perl filehandle for reading and writing *CLIENT = $client_obj->perlfh(); print CLIENT "stuff"; #### close client connection close(CLIENT); #### stop advertising service $service_obj->stopservice(); #### close server connection $obj->close(); DESCRIPTION
This module creates a Bluetooth interface for Perl. Net::Bluetooth works with the BlueZ libs as well as with Microsoft Windows. If you are going to be using a Unix system, the Bluez libs can be obtained at www.bluez.org. Please make sure these are installed and working properly before you install the module. Depending on your system BlueZ maybe already installed, or you may have to build it yourself and do some configuration. You can verify that BlueZ can detect devices and services with the utilities that are included with it (hciconfig, sdptool, hcitool, etc). If you are using Windows, please make sure you have Service Pack 2 installed and the Microsoft Platform SDK. Also please make sure the "$win_include" variable at the top of Makfile.PL is set properly. This needs to point to the SDK include directory for SP2. This is where the module will look for all the Bluetooth header files (ws2bth.h, etc). Please check out the samples included in the samples directory for more general information. FUNCTIONS
get_remote_devices() Searches for remote Bluetooth devices. The search will take approximately 5 - 10 seconds (This will be a configurable value in the future.). When finished, it will return a hash reference that contains the device address and name. The address is the key and the name is the value. Name will be set to "[unknown]" if the name could not be resolved. See the NOTES section of this document for more information about this. sdp_search($addr, $uuid, $name) This searches a specific device for service records. The first argument is the device address which is not optional. The uuid argument can be a valid uuid or "0". The name argument can be a valid service name or "". It will return services that match the uuid or service name if supplied, otherwise it will return all public service records for the device. The return value is a list which contains a hash reference for each service record found. The key/values for the hash are as follows: "SERVICE_NAME": Service Name "SERVICE_DESC": Service Description "SERVICE_PROV": Service Provider "RFCOMM": RFCOMM Port "L2CAP": L2CAP Port "UNKNOWN": Unknown Protocol Port If any of the values are unavailable, the keys will not exist. If $addr is "localhost" the call will use the local SDP server. SOCKET OBJECT
The bluetooth socket object is used to create bluetooth sockets and interface with them. There are two types of sockets supported, RFCOMM and L2CAP. The methods are listed below. newsocket("RFCOMM") This constructs a socket object for a RFCOMM socket or L2CAP socket. connect($addr, $port) This calls the connect() system call with the address and port you supply. You can use this to connect to a server. Returns 0 on success. bind($port) This calls the bind() system call with the port you provide. You can use this to bind to a port if you are creating a server. Returns 0 on success. As a side note, RFCOMM ports can only range from 1 - 31. listen($backlog) This calls the listen() system call with the backlog you provide. Returns 0 on success. accept() This calls the accept() system call and creates a new bluetooth socket object which is returned. On failure it will return undef. perlfh() This call returns a Perl filehandle for a open socket. You can use the Perl filehandle as you would any other filehandle, except with Perl functions that use the socket address structure. This provides a easy way to do socket IO instead of doing it through the socket object. Currently this is the only way to do socket IO, although soon I will provide read/write calls through the object interface. close() This closes the socket object. This can also be done through the Perl close() call on a created Perl filehandle. getpeername() This returns the address and name for a open bluetooth socket. (BlueZ only for now) SERVICE OBJECT
The service object allows you to register a service with your local SDP server. The methods are as follows: newservice($obj, $service_uuid, $service_name, $service_desc) This registers a service with your local SDP server. The first argument is a open and bound socket that you created with newsocket(). The second argument is the service uuid. The third argument is the service name. The fourth argument is the service description. The return value is a new service object. This will be undefined if there was an error. stop_service() This unregisters your service with the local SDP server. The service will be unregistered without this call when the application exits. NOTES
All uuids used with this module can either be 128 bit values: "00000000-0000-0000-0000-000000000000" or 16 bit values: "0000". All values must be represented as strings (enclosed in quotes), and must be hexadecimal values. Windows will not immediately return the device name if it is not already cached. Also there is no mechinism to alert the system when it has acquired the device name. Therefore you may have to call get_remote_devices() twice before the name shows up. I'll see if this can be handled better in the future. Currently on Windows the service name and description returned by sdp_search() are not setting their terminating NULL character properly. This can result in some garbage characters at the end of the string. I am looking at parsing the raw record to fix this problem. REQUIREMENTS
You need BlueZ or Microsoft Service Pack 2 installed and the Microsoft Platform SDK. Windows needs at least Perl 5.8. AUTHOR
Ian Guthrie IGuthrie@aol.com Copyright (c) 2006 Ian Guthrie. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. SEE ALSO
perl(1). perl v5.14.2 2007-08-12 Bluetooth(3pm)
All times are GMT -4. The time now is 08:10 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy