Sponsored Content
Top Forums Shell Programming and Scripting Want to sort a file using awk & sed to get required output Post 302721563 by msabhi on Thursday 25th of October 2012 02:23:03 PM
Old 10-25-2012
Code:
perl -alne '{if(/^\d/) {$val=$F[0];$F[3]=~s/.*?-(\w+):(\d)/$1 $2/;print "$F[0] $F[1] $F[3]";} else{
if(/^ +/){$F[2]=~s/.*?-(\w+):(\d)/$1 $2/;print "$val $F[0] $F[2]";next;}}}' input_file

Hope this helps..
This User Gave Thanks to msabhi For This Post:
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

sed & awk--get section of file based 2 params

I need to get a section of a file based on 2 params. I want the part of the file between param 1 & 2. I have tried a bunch of ways and just can't seem to get it right. Can someone please help me out.....its much appreciated. Here is what I have found that looks like what I want....but doesn't... (12 Replies)
Discussion started by: Andy Cook
12 Replies

2. Shell Programming and Scripting

Problem to add the string(without sed & awk) into the middle of file

Hi, I have tried many times to add the string into the first line of the file or the middle of the file but could not find the solution. I first tried by $echo "paki" >> file This code only append paki string at the end of file "file" but how can i add this "paki" into the first line or... (5 Replies)
Discussion started by: ali hussain
5 Replies

3. Shell Programming and Scripting

SED/AWK file read & manipulation

I have large number of data files, close to 300 files, lets say all files are same kind and have extension .dat , each file have mulitple lines in it. There is a unique line in each file containing string 'SERVER'. Right after this line there is another line which contain a string 'DIGIT=0',... (4 Replies)
Discussion started by: sal_tx
4 Replies

4. Shell Programming and Scripting

Awk & sed query for output

Hello, I have a file. its content are like below. mdn:87439842 imsi:23082038203 Ctime:12082010 01:20:10 mdn:9324783783 imsi:402349823322 Ctime: 12072010 01:20:10 mdn:87439842 imsi:23082038203 Ctime: 23072010 01:20:10 mdn:87439842 imsi:23082038203 Ctime:18072010 01:20:10 mdn:87439842... (3 Replies)
Discussion started by: Sanket11
3 Replies

5. Shell Programming and Scripting

Sort a the file & refine data column & row format

cat file1.txt field1 "user1": field2:"data-cde" field3:"data-pqr" field4:"data-mno" field1 "user1": field2:"data-dcb" field3:"data-mxz" field4:"data-zul" field1 "user2": field2:"data-cqz" field3:"data-xoq" field4:"data-pos" Now i need to have the date like below. i have just... (7 Replies)
Discussion started by: ckaramsetty
7 Replies

6. UNIX for Advanced & Expert Users

Using awk or sed need the output in the new file

Please find the input file as given below: 2012/02/29 11:00:00~~CRITICAL~For customer 00000476 no daily files were found in the 010137933 account directory. 2012/02/29 11:00:00~~CRITICAL~For customer 05006802 no daily files were found in the 010115166 account directory. 2012/02/29... (0 Replies)
Discussion started by: av_sagar
0 Replies

7. Shell Programming and Scripting

awk help: Match data fields from 2 files & output results from both into 1 file

I need to take 2 input files and create 1 output based on matches from each file. I am looking to match field #1 in both files (Userid) and create an output file that will be a combination of fields from both file1 and file2 if there are any differences in the fields 2,3,4,5,or 6. Below is an... (5 Replies)
Discussion started by: ambroze
5 Replies

8. Shell Programming and Scripting

Replacing FQDN by hostnames in a CSV file with sed & awk

Hello, Beginning with shell scipting, I'm trying to find in a csv file, the lines where the field related to hostname is displayed as an FQDN intead the hostname. (some lines are correct) and the to correct that inside the file: Novell,11.0,UNIX Server,bscpsiws02,TxffnX1tX1HiDoyBerrzWA==... (2 Replies)
Discussion started by: Wonto
2 Replies

9. Shell Programming and Scripting

File Move & Sort by Name - Kick out Bad File Names & More

I have a dilemma, we have users who are copying files to "directory 1." These images have file names which include the year it was taken. I need to put together a script to do the following: Examine the file naming convention, ensuring it's the proper format (e.g. test-1983_filename-123.tif)... (8 Replies)
Discussion started by: Nvizn
8 Replies
Poet::Util::Debug(3pm)					User Contributed Perl Documentation				    Poet::Util::Debug(3pm)

NAME
Poet::Util::Debug - Debug utilities SYNOPSIS
# In a script... use Poet::Script; # In a module... use Poet; # Automatically available in Mason components # then... # die with value dd $data; # print value to STDERR dp $data; # print value to logs/console.log dc $data; # return value prepped for HTML dh $data; # same as above with full stacktraces dds $data; dps $data; dcs $data; dhs $data; DESCRIPTION
These debug utilities are automatically imported wherever "use Poet" or "use Poet::Script" appear, and in all components. Because let's face it, debugging is something you always want at your fingertips. However, for safety, the short named versions of these utilities are no-ops outside of development mode, in case debug statements accidentally leak into production (we've all done it). You have to use longer, less convenient names outside of development for them to work. UTILITIES
Each of these utilities takes a single scalar value. The value is serialized with Data::Dumper and prefixed with a file name, line number, and pid. e.g. dp { a => 5, b => 6 }; prints to STDERR [dp at ./d.pl line 6.] [1436] { a => 5, b => 6 } The variants suffixed with 's' additionally output a full stack trace. dd ($val), dds ($val) Die with the serialized $val. dp ($val), dps ($val) Print the serialized $val to STDERR. Useful in scripts. dc ($val), dcs ($val) Append the serialized $val to "console.log" in the "logs" subdirectory of the environment. Useful as a quick alternative to full-bore logging. dh ($val), dhs ($val) Returns the serialized $val, surrounded by "<pre> </pre>" tags. Useful for embedding in Mason components, e.g. <% dh($data) %> Live variants Each of the functions above must be appended with "_live" in order to work in live mode. e.g. # This is a no-op in live mode dp [$foo]; # but this will work dp_live [$foo]; SEE ALSO
Poet AUTHOR
Jonathan Swartz <swartz@pobox.com> COPYRIGHT AND LICENSE
This software is copyright (c) 2012 by Jonathan Swartz. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. perl v5.14.2 2012-06-05 Poet::Util::Debug(3pm)
All times are GMT -4. The time now is 06:13 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy