Sponsored Content
Top Forums Shell Programming and Scripting Getting fields from a file having multiple delimiters Post 302993344 by Don Cragun on Thursday 9th of March 2017 03:42:35 AM
Old 03-09-2017
Assuming that your input sample is representative:
Code:
awk -F, -v sq="'" '{match($0, /".*"/); print $1, $4, $6, sq substr($0, RSTART+1, RLENGTH-2) sq, $(NF-1)}' file

seems to do what you want.

If you are running this on a Solaris/SunOS system, change awk to /usr/xpg4/bin/awk or nawk.
This User Gave Thanks to Don Cragun For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

join on a file with multiple lines, fields

I've looked at the join command which is able to perform what I need on two rows with a common field, however if I have more than two rows I need to join all of them. Thus I have one file with multiple rows to be joined on an index number: 1 randomtext1 2 rtext2 2 rtext3 3 rtext4 3 rtext5... (5 Replies)
Discussion started by: crimper
5 Replies

2. Shell Programming and Scripting

Cutting a file with multiple delimiters into columns

Hi All I have recently had to start using Unix for work and I have hit brick wall with this prob.... I have a file that goes a little something like this.... EUR;EUR;EUR:USD:USD;USD;;;EUR/USD;XAU/AUD;XAU/EUR;XAU/AUD,GBP/BOB,UAD/XAU;;;1.11;2.22;3.33;4.44;5.55;6.66;;; is it possible to... (7 Replies)
Discussion started by: luckycharm
7 Replies

3. Shell Programming and Scripting

AWK with multiple delimiters

I have the following string sample: bla bla bla bla bla I would like to extract the "123" using awk. I thought about awk -F"]" '{ print $1 }' but it doesn't work Any ideas ? (7 Replies)
Discussion started by: gdub
7 Replies

4. Shell Programming and Scripting

Sorting problem: Multiple delimiters, multiple keys

Hello If you wanted to sort a .csv file that was filled with lines like this: <Ticker>,<Date as YYYYMMDD>,<Time as H:M:S>,<Volume>,<Corr> (H : , M, S: ) by date, does anybody know of a better solution than to turn the 3rd and 4th colons of every line into commas, sorting on four keys,... (20 Replies)
Discussion started by: Ryan.
20 Replies

5. Shell Programming and Scripting

Inserting additional comma delimiters in a csv file, after and before certian fields.

Hello I have a csv file which I need to insert addtional commas into. The csv is of the format field1,field2,field3,field4,...etc...,field13,field14 I need to add extra commas in each record so that the final output looks like ... (1 Reply)
Discussion started by: kamal_p_99
1 Replies

6. Shell Programming and Scripting

awk: Print fields between two delimiters on separate lines and send to variables

I have email headers that look like the following. In the end I would like to accomplish sending each email address to its own variable, such as: user1@domain.com='user1@domain.com' user2@domain.com='user2@domain.com' user3@domain.com='user3@domain.com' etc... I know the sed to get rid of... (11 Replies)
Discussion started by: tay9000
11 Replies

7. Shell Programming and Scripting

awk multiple delimiters

Hi Folks, This is the first time I ever encountered this situation My input file is of this kind cat input.txt 1 PAIXAF 0 1 1 -9 0 0 0 1 2 0 2 1 2 1 7 PAIXEM 0 7 1 -9 1 0 2 0 1 2 2 1 0 2 9 PAKZXY 0 2 1 -9 2 0 1 1 1 0 1 2 0 1 Till the sixth column (which is -9), I want my columns to... (4 Replies)
Discussion started by: jacobs.smith
4 Replies

8. UNIX for Dummies Questions & Answers

Cut fields between delimiters

I'm having bother getting both lines contained in a file to output as the same value. A simple example: john:123456:123:456:doe john:123456:123:doe cut -d: -f1,4 input file john:456 john:doe ^ first line should be same as second. trick one for me, i know why it's because of the... (4 Replies)
Discussion started by: landofus
4 Replies

9. Shell Programming and Scripting

Cut counting consecutive delimiters as fields

When cut encounters consecutive delimiters it seems to count each instance as a field, at least with spaces. Is this typical behavior for any delimiter? #:~$ ifconfig eth0 | grep HWaddr eth0 Link encap:Ethernet HWaddr 94:de:80:a7:6d:e1 #:~$ ifconfig eth0 | grep HWaddr | cut -d " " -f... (6 Replies)
Discussion started by: Riker1204
6 Replies

10. Shell Programming and Scripting

Shell Script to Group by Based on Multiple Fields in a file

Hi, I want to know if there is any simple approach to SUM a field based on group by of different fields for e.g. file1.txt contains below data 20160622|XXX1||50.00||50.00|MONEY|Plan1| 20160622|XXX1||100.00||100.00|MONEY|Plan1| 20160623|XXX1||25.00||25.00|MONEY|Plan1|... (3 Replies)
Discussion started by: cnu_theprince
3 Replies
PTS_ADDUSER(1)						       AFS Command Reference						    PTS_ADDUSER(1)

NAME
pts_adduser - Adds a user or machine to a Protection Database group SYNOPSIS
pts adduser -user <user name>+ -group <group name>+ [-cell <cell name>] [-noauth] [-localauth] [-force] [-help] pts ad -u <user name>+ -g <group name>+ [-c <cell name>] [-n] [-l] [-f] [-h] DESCRIPTION
The pts adduser command adds each user or machine entry named by the -user argument as a member of each group named by the -group argument. To remove members of a group, use the pts removeuser command. To list the groups to which a user or machine belongs, or the members of a specified group, use the pts membership command. CAUTIONS
After being added as a group member, a currently authenticated user must reauthenticate (for example, by issuing the aklog or klog.krb5 commands) to obtain permissions granted to the group on an access control list (ACL). OPTIONS
-user <user name>+ Specifies the name of each user or machine entry to add to each group named by the -group argument. The name of a machine entry resembles an IP address and can use the wildcard notation described on the pts createuser reference page. The user or machine entry must already exist in the Protection Database. -group <group name>+ Specifies the complete name (including the owner prefix if applicable) of each group to which to add members. The group entry must already exist in the Protection Database. -cell <cell name> Names the cell in which to run the command. For more details, see pts(1). -force Enables the command to continue executing as far as possible when errors or other problems occur, rather than halting execution at the first error. -help Prints the online help for this command. All other valid options are ignored. -localauth Constructs a server ticket using a key from the local /etc/openafs/server/KeyFile file. Do not combine this flag with the -cell or -noauth options. For more details, see pts(1). -noauth Assigns the unprivileged identity anonymous to the issuer. For more details, see pts(1). EXAMPLES
The following example adds user smith to the group system:administrators. % pts adduser -user smith -group system:administrators The following example adds users "jones", "terry", and pat to the smith:colleagues group. % pts adduser -user jones terry pat -group smith:colleagues The following example adds the machine entries in the ABC Corporation subnet to the group "bin-prot". Because of the IP address range of the ABC Corporation subnet, the system administrator was able to group the machines into three machine entries (using the wildcard notation discussed on the pts createuser reference page). % pts adduser -user 138.255.0.0 192.12.105.0 192.12.106.0 -group bin-prot PRIVILEGE REQUIRED
The required privilege depends on the setting of the fourth privacy flag in the Protection Database entry for each group named by the -group argument (use the pts examine command to display the flags): o If it is the hyphen, only the group's owner and members of the system:administrators group can add members. o If it is lowercase "a", current members of the group can add new members. o If it is uppercase "A", anyone who can access the cell's database server machines can add new members. SEE ALSO
pts(1), pts_createuser(1), pts_examine(1), pts_membership(1), pts_removeuser(1), pts_setfields(1) COPYRIGHT
IBM Corporation 2000. <http://www.ibm.com/> All Rights Reserved. This documentation is covered by the IBM Public License Version 1.0. It was converted from HTML to POD by software written by Chas Williams and Russ Allbery, based on work by Alf Wachsmann and Elizabeth Cassell. OpenAFS 2014-04-08 PTS_ADDUSER(1)
All times are GMT -4. The time now is 09:16 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy