01-03-2012
using awk in perl with split command
Hi,
I have an array with following data. First field shows the owner and second is unique name. Now i have to pic the latest value with respect to the date in case of duplicate.
like "def" is from two owners "rahul/vineet", now i want the latest from the two and the owner name also for all the fields
ARRAY:
rahul_abc_Linux_Nov_02
rahul_def_Linux_Nov_02
vineet_cde_Linux_Dec_05
vineet_def_Linux_Dec_01
vineet_kbc_Linux_Dec_06
expected result
ARRAY:
rahul_abc_Linux_Nov_02
vineet_cde_Linux_Dec_05
vineet_def_Linux_Dec_01
vineet_kbc_Linux_Dec_06
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi,
I have a problem in grepping a file for 2 strings and writing them to 2 appropriate files. I need to use the awk command and read the file only once and write to the appropriate file.
My file is very huge in size and it is taking a long time using cat command and grep command.
Can anyone... (3 Replies)
Discussion started by: m_subra_mani
3 Replies
2. Shell Programming and Scripting
Hi,
I am trying to use the split commad to seperate string reading from file. but it dosent give me a correct result. can some body tell me what is the wrong in following scritp.
#!/usr/bin/perl -w
#use CGI qw(:standard); ... (2 Replies)
Discussion started by: maheshsri
2 Replies
3. UNIX for Advanced & Expert Users
Hi,
I have to split a line of the form
1232423#asdf#124324#54534#dcfg#wert#rrftt#4567
into an array in perl. I am using
@fields;
@fields=split('#',$line);
if($fields eq "1")
But this is not working. By using the syntax, the statements in "if" are never executed. Please help.... (9 Replies)
Discussion started by: rochitsharma
9 Replies
4. Shell Programming and Scripting
Hi All,
Can someone please help me write a script for the following requirement in awk, grep, sed or perl.
Buuuu xxx bbb
Kmmmm rrr ssss uuuu
Kwwww zzzz ccc
Roooowwww eeee
Bxxxx jjjj dddd
Kuuuu eeeee nnnn
Rpppp cccc vvvv cccc
Rhhhhhhyyyy tttt
Lhhhh rrrrrssssss
Bffff mmmm iiiii
Ktttt... (5 Replies)
Discussion started by: kumarn
5 Replies
5. Shell Programming and Scripting
Hi
I have few files with format access.2Nov-12:15AM.
These files will be generated daily . I need to write a script so that if today's date is less than 10 then it has to zip the file and rename it to
acess.02Nov-12:15AM.gz .please help me in this . Also please help me
in splitting the file... (10 Replies)
Discussion started by: mskalyani9
10 Replies
6. Shell Programming and Scripting
awk 'FNR == 1 { c = 1 } { print > (f c) } !FNR%n { close(f c); ++c }' n=$files_per_stream f=$input_path/filename_ $input_file
$input_file with some records are splitted into files named filename_1,filename_2...etc according to $files_per_stream.
Plz help me know how and if anyone has... (7 Replies)
Discussion started by: guptam
7 Replies
7. Shell Programming and Scripting
Hi,
There is an awk command in script and it is running successfully.
I want to split that command in 2 lines.
I have tried using '\' but its not working..
Please suggest me the solution. (11 Replies)
Discussion started by: Sanket Dalvi
11 Replies
8. Shell Programming and Scripting
Dear all,
I am using the awk 'split' command to get the particular value.
FILE=InputFile_009_0.txt
Temp=$(echo $FILE | awk '{split($FILE, a, "e_"); print a}')
I would like to have the Temp take the value as : _009_0
... (4 Replies)
Discussion started by: emily
4 Replies
9. Shell Programming and Scripting
I am trying to run the awk below. My question is when I split the input, then run anotherawk to perform a calculation using that splitas the input there are no issues. When I try to combine them the output is not correct, is the split not working or did I do it wrong? Thank you :).
input
... (8 Replies)
Discussion started by: cmccabe
8 Replies
10. UNIX for Beginners Questions & Answers
Hello,
I need to split a pipe de-limited file based on the COLUMN 7 value . If the column value changes I need to split the file
Source File
Payment|ID|DATE|TIME|CONTROLNUMBER|NUMBER|NAME|INDICATOR
42156974|1137937|10/1/2018|104440|4232|2054391|CARE|1... (9 Replies)
Discussion started by: rosebud123
9 Replies
LEARN ABOUT HPUX
diskowner
diskowner(1M) diskowner(1M)
NAME
diskowner - retrieve the owner of a storage device
SYNOPSIS
path
DESCRIPTION
The command is used to retrieve the subsystem, if any, which is using the specified path. The command is intended to help prevent users
from overwriting storage that is already in use. The command will print out the owner of the path, or if no owner was found. A storage
device is considered owned by a subsystem if it has been formatted by that subsystem. For example, if a disk contains a VxFS filesystem,
but is not mounted or in use, it is still considered owned by the VxFS subsystem.
If the path specified is invalid or inaccessible, an error message will be printed.
Options and Arguments
The command recognizes the following options and arguments:
path The path name to the storage device. The path may be a symbolic link, as long as it points to a storage device, such as a file,
disk, or logical volume.
List all the owners of the specified path, seperated by commas
Produce a compact output that is easily parsed by other scripts and
programs. When used with option, displays all the owners seperated by dots This format is described in the section below.
Output from diskowner
displays the following possible output:
owner The owner of the given path. owner can be one of the following:
The path is not owned by any known subsystem.
The path is part of an LVM volume group.
The path is part of a VxVM volume group.
The path has a VxFS filesystem on it.
The path has a HFS filesystem on it.
The path is being used as a swap device.
The path is being used as a dump device.
The path is part of an Oracle database.
The path has EFI partitions on it.
message An error message displayed when the given path is invalid or inaccessible.
Compact Listing
The option generates a compact, colon delimited listing that is easy to parse. The output format is:
and so forth.
The option, when used with the option, produces this output format:
and so forth.
The current command prints out the keys and values listed below. In the future, new keys and/or values may be added to the output.
or
or
where
path is the pathname passed as argument
owner is the owner of the given path
message is an error message when given path is invalid or inaccessible.
n is number of owners of the given path
EXTERNAL INFLUENCES
Environment Variables
determines the language in which messages are displayed.
If is not specified or is null, it defaults to "C" (see lang(5)).
If any internationalization variable contains an invalid setting, all internationalization variables default to "C" (see environ(5)).
RETURN VALUE
Upon completion, returns one of the following values:
The path is not owned (the owner is
The path is already owned by a subsystem.
The path does not exist.
Invalid options or library version incompatible.
The path cannot be opened due to an I/O error.
The path cannot be opened due to insufficient permissions.
The path format is invalid.
EXAMPLES
Display the owner of a disk path:
Display the owner of a logical volume in compact output:
Display all the owners of a disk path:
Display all the owners of a logical volume in compact output:
SEE ALSO
crashconf(1M), df(1M), swapinfo(1M), vgdisplay(1M), vxvmboot(1M), vxassist(1M), fstab(4).
diskowner(1M)