Sponsored Content
Top Forums Shell Programming and Scripting Getting Distinct values from second field in a file.... Post 302333869 by dennis.jacob on Tuesday 14th of July 2009 08:09:15 AM
Old 07-14-2009
Another one :

Code:
awk -F"|" ' { arr[$2]; } END { for (i in arr) print i; }'  filename

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Loop through only the distinct values in a file

Datafile has the following data seperated by : FIELD1:FIELD2:FIELD3 D1:/opt/9.1.9:Y D2:/opt/10.1.10:Y D3:/opt/9.1.9:Y D4:/opt/8.1.8:Y D5:/opt/8.1.8:Y D6:/opt/9.1.9:Y D7:/opt/9.1.9:Y D8:/opt/10.1.10:Y D9:/opt/9.1.9:Y D10:/opt/10.1.10:Y I want to do some operations only on the distinct... (2 Replies)
Discussion started by: pbekal
2 Replies

2. Shell Programming and Scripting

grep distinct values

this is a little more complex than that. I have a text file and I need to find all the distinct words that appear in a line after the word TABLESPACE when I grep for just the word tablespace, I get: how do i parse this a little better so i have a smaller file to read? This is just an... (4 Replies)
Discussion started by: guessingo
4 Replies

3. Shell Programming and Scripting

Select distinct values from a flat file

Hi , I have a similar problem. Please can anyone help me with a shell script or a perl. I have a flat file like this fruit country apple germany apple india banana pakistan banana saudi mango india I want to get a output like fruit country apple ... (7 Replies)
Discussion started by: smalya
7 Replies

4. UNIX for Dummies Questions & Answers

distinct values of all the fields

I am a beginner to scripting, please help me in this regard. How do I create a script that provides a count of distinct values of all the fields in the pipe delimited file ? I have 20 different files with multiple columns in each file. I needed to write a generic script where I give the number... (1 Reply)
Discussion started by: vukkusila
1 Replies

5. Shell Programming and Scripting

distinct values of all the fields

I am a beginner to scripting, please help me in this regard. How do I create a script that provides a count of distinct values of all the fields in the pipe delimited file ? I have 20 different files with multiple columns in each file. I needed to write a generic script where I give the number... (2 Replies)
Discussion started by: vukkusila
2 Replies

6. Shell Programming and Scripting

average of distinct values with awk

Hi guys, I am not an expert in shell and I need help with awk command. I have a file with values like 200 1 1 200 7 2 200 6 3 200 5 4 300 3 1 300 7 2 300 6 3 300 4 4 I need resulting file with averages of... (3 Replies)
Discussion started by: saif
3 Replies

7. Shell Programming and Scripting

Get the distinct of a particular field

From the below ps output , I want the distinct values of the third field (ie. I need the distinct PPIDs) $ ps -ef UID PID PPID C STIME TTY TIME CMD root 1 0 0 Nov 10 - 48:49 /etc/init root 1769576 1 0 Nov 10 - 0:07... (1 Reply)
Discussion started by: polavan
1 Replies

8. Shell Programming and Scripting

Find distinct values

Hi, I have two files of the following format file1 chr1:345-456 chr2:123-456 chr2:455-678 chr3:456-789 chr3:444-555 file2 chr1:345-456 chr2:123-456 chr3:456-789 output (2 Replies)
Discussion started by: jacobs.smith
2 Replies

9. Shell Programming and Scripting

Command to identify distinct field value

Could anyone help me on a command to identify distinct values from a particular column ?my input file has header. So i need a command in which we pass Column1 as parameter. For eg my input is like Column1 Column2 Column3 ... (4 Replies)
Discussion started by: krish123
4 Replies

10. Shell Programming and Scripting

Need distinct values from command in a script

Hello, I am using below command srvctl config service -d cmdbut cmdbut_01 (P):/devoragridcn_01/app/oracle> srvctl config service -d cmdbut Service name: boms10.world Service is enabled Server pool: cmdbut_boms10.world Cardinality: 1 Disconnect: false Service role: PRIMARY Management... (7 Replies)
Discussion started by: Vishal_dba
7 Replies
XATTR(1)						    BSD General Commands Manual 						  XATTR(1)

NAME
xattr -- display and manipulate extended attributes SYNOPSIS
xattr [-lrsvx] file ... xattr -p [-lrsvx] attr_name file ... xattr -w [-rsx] attr_name attr_value file ... xattr -d [-rsv] attr_name file ... xattr -c [-rsv] file ... xattr -h | --help DESCRIPTION
The xattr command can be used to display, modify or remove the extended attributes of one or more files, including directories and symbolic links. Extended attributes are arbitrary metadata stored with a file, but separate from the filesystem attributes (such as modification time or file size). The metadata is often a null-terminated UTF-8 string, but can also be arbitrary binary data. One or more files may be specified on the command line. For the first two forms of the command, when there are more than one file, the file name is displayed along with the actual results. When only one file is specified, the display of the file name is usually suppressed (unless the -v option described below, is also specified). In the first form of the command (without any other mode option specified), the names of all extended attributes are listed. Attribute names can also be displayed using ``ls -l@''. In the second form, using the -p option (``print''), the value associated with the given attribute name is displayed. Attribute values are usually displayed as strings. However, if nils are detected in the data, the value is displayed in a hexadecimal representation. The third form, with the -w option (``write''), causes the given attribute name to be assigned the given value. The fourth form, with the -d option (``delete''), causes the given attribute name (and associated value), to be removed. In the fifth form, with the -c option (``clear''), causes all attributes (including their associated values), to be removed. Finally, the last form, with either the -h or --help option, displays a short help message and exits immediately. OPTIONS
-l By default, the first two command forms either displays just the attribute names or values, respectively. The -l option causes both the attribute names and corresponding values to be displayed. For hexadecimal display of values, the output is preceeded with the hexadeci- mal offset values and followed by ASCII display, enclosed by ``|''. -r If a file argument is a directory, act as if the entire contents of the directory recursively were also specified (so that every file in the directory tree is acted upon). -s If a file argument is a symbolic link, act on the symbolic link itself, rather than the file that the symbolic link points at. -v Force the the file name to be displayed, even for a single file. -x Force the attribute value to be displayed in the hexadecimal representation. The -w option normally assumes the input attribute value is a string. Specifying the -x option causes xattr to expect the input in hexa- decimal (whitespace is ignored). The xxd(1) command can be used to create hexadecimal representations from exising binary data, to pass to xattr. EXIT STATUS
The xattr command exits with zero status on success. On error, non-zero is returned, and an error message is printed to the standard error. For system call errors, both the error code and error string are printed (see getxattr(2), listxattr(2), removexattr(2) and setxattr(2) for a complete list of possible error codes). Some attribute data may have a fixed length that is enforced by the system. For example, % xattr -w com.apple.FinderInfo 0 foo xattr: [Errno 34] Result too large: 'foo' The com.apple.FinderInfo attribute must be 32 bytes in length. EXAMPLES
This example copies the com.apple.FinderInfo attribute from the /usr directory to the MyDir directory: % xattr -px com.apple.FinderInfo /usr 00 00 00 00 00 00 00 00 40 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 % xattr -l MyDir % xattr -wx com.apple.FinderInfo "`xattr -px com.apple.FinderInfo /usr`" MyDir % xattr -l MyDir com.apple.FinderInfo: 00000000 00 00 00 00 00 00 00 00 40 00 00 00 00 00 00 00 |........@.......| 00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| 00000020 SEE ALSO
ls(1), xxd(1), getxattr(2), listxattr(2), removexattr(2), setxattr(2) BSD
Nov 29, 2010 BSD
All times are GMT -4. The time now is 06:29 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy