General :: Display String In Row / Column - Time Sorting Operation?

Aug 13, 2010

1. Given a string, row no. and col. no., I want to display it in the screen appropriately. how to do this?
2. How can I find the cpu processing time taken in carrying out the sorting task (any sorting program)?

View 4 Replies


ADVERTISEMENT

General :: Awk Gsub() Command - String (column) Manipulation - Replace The Value Of The $1 Column In The Awk Print String?

Mar 7, 2010

i use this script to get the time and date of back and fourth transactions for a particular execution id. I use a substr command on the 5th column to to cut the milli seconds off the time value. - otherwise the times would look like 08:30:04.235

grep <executionID> <auditfile> | awk '{ print $1, $2, $3, $4, substr($5,1,8}
FIX -> Mon 3/1/2010 08:30:04
FIX <- Mon 3/1/2010 08:32:36
FIX <- Mon 3/1/2010 08:35:08

[code].....

anyhow - i append two sed commands to further clarify the direction of the message.

awk '{ print $1, $2, $3, $4, substr($5,1,8} | sed -e 's/->/ ->IN/g' | sed -e 's/<-/<-OUT/g'
FIX -> IN Mon 3/1/2010 08:30:04
FIX <- OUT Mon 3/1/2010 08:32:36

[code]....

I tried using an awk gsub () command within the string instead of the two seds, but it did not work:

awk '{ print gsub(/<regex>/, <replace with>,$1), $2, $3, $4, substr($5,1,8}

the sed works ok, but it would be cooler to make the replacement within the awk command:

gsub(/->/,-> IN, $1)

Is there a way where i could replace the value of the $1 column in the awk print string?

View 1 Replies View Related

General :: Sorting A First Non-numerical Column In A File?

Jul 13, 2011

I have a file like:

ER- V67
ER+ V68
ER- V69
ER+ V70

[Code]....

I am using the code:

sort -k1

but it prints it by sorting the second column.

View 8 Replies View Related

General :: Sorting Output By A Column With Numbers And Letters

May 22, 2011

I have a program that prints out lines like:

And I want to be able to pipe it to sort on that third column, by letter first, then number. But I keep coming getting files sorted like:

(field separations all start at same place, so columns are not jagged like above.)

I have read the sort man pages, and have tried -n for the numbers, and -k for the position to start sorting, among other things. I also tried inputting a second position to start sorting, which sort should supposedly refer to if the two entries are identical at the first place being compared, but it seems to just ignore the second one. I just can't get it to sort the numbers properly...

For now I am manually opening the file in emacs and changing them around, needless to say, very time consuming.

View 13 Replies View Related

Programming :: PHP - Sorting Multi Dimensional Arrays By One Column

Mar 17, 2009

I just started programming in PHP so I haven't figured out how to do this yet, but I have a multi-dimensional array that I need to sort by one column. That's fine...but I need the sort to ignore case! Right now I have it sorted by 'name' (the other column is 'uid').

The problem is that by the default the sort is case-sensitive so the array looks like this:
Code:
Apple 4015
Banana 4011
Cherry 4045
avocado 4046

I want to be able to sort the the 'name' column in a case-insensitive manner so that the array actually looks like:
Code:
Apple 4015
avocado 4046
Banana 4011
Cherry 4045

How to accomplish this? Just FYI I'm not actually sorting the PLUs for fruits...but it was a simple example. I'm actually doing this for a Facebook application.

View 2 Replies View Related

Programming :: Search A String And Print Column?

Mar 13, 2010

I need to search a string which is in the first line and print that column.

For e.g

Code:
$ top -bn1 | head -20 | awk '/PID/,/*/'
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 13737 admin 15 0 2476 936 680 R 2 0.0 0:00.01

[Code]....

View 6 Replies View Related

General :: Calculate 3rd Column Which Should Be Addition Of Value In 1 And 2nd Column?

Jul 19, 2010

How would i calculate following values.Initial file

10 3
20 4
How would i calculate 3rd column which should be addition of value in 1 and 2nd column.File after calculation
10 3 13
20 4 24

View 14 Replies View Related

General :: Search A String In Logs Of Last 15 Minutes From Current Time?

Aug 26, 2010

I want to run a script that runs after every 15 minutes that i will do using crontab. But in script want to search a string from the last 15 minutes logs in log file containing data of whole day.

how i can search the string according to time difference that is logs from from current time and current time - 15 minutes.

Sample logs are as follows:

26-Aug-2010 16:38:46,055|9172310750|subscription_app|31ba267e%3A12aadd47bdc%3A50e9|ChargeAmount|ChargingIntercep tor - subscriber details processed sucessfully- {arg0.referenceCode=balanceEnquiry:true;subsChannel:Unknown;channelType:Subscription;transactionId:3

[Code]....

View 6 Replies View Related

Programming :: How To Sort Two MySQL Table On Date Or Time Column

Jul 27, 2011

I have two different table in a database in mysql that has no share key with each other and I want to sort them with each other on their date time column I mean when I sort it row X of table A that is older that row Y of table B comes earlier.

View 3 Replies View Related

General :: Unix Ps -l Priority Whoes One Number In Column "PRI" But In Same Time Ps -o Pri Shows Another Number?

May 21, 2011

Why does unix ps -l whows one number in column "PRI" but in same time ps -o pri shows another number? cpu and nice are zero for those processes

View 1 Replies View Related

General :: Display On Two Machines At Same Time

Mar 18, 2011

I'd like to know if it's possible to set the DISPLAY environment variable in order to display on two machines, the local and the remote, at the same time.

View 2 Replies View Related

General :: How To Display Users Log On Time?

Feb 28, 2010

I was wondering how could I display a list of all of my users and their log on time, you know like small reports on what user was connected for how long.

View 5 Replies View Related

General :: Sed To Display The Pattern String - The Line Above It And The First Line Of That Para

Mar 30, 2011

I need to grep for a particular string and if found need to display the line containing that string, the line above that and also the first line of that paragraph.

Can this be done via sed.

Eg, My Paragraphs

OA connectA

Enclosure:

Interconnect Module #6 Status:

Here, if I grep for Critical, it should display the following

Similarly if I grep for Degraded, it should display

View 3 Replies View Related

OpenSUSE :: Software To Display Time From Multiple Time Zones?

Jun 15, 2011

I'm looking for a program that will digitally display the time in three different cities - all showing at once. I don't care if it is a panel applet or stand-alone. I'm using Suse 11.3 and Gnome.

View 5 Replies View Related

General :: Write File And Display In Terminal At Same Time

Sep 30, 2010

How can we write a file and display in terminal at the same time. Like for example, when I do..
php -f file.php > testfile
That should save right.. but I want to display it in terminal otherwise.

View 4 Replies View Related

General :: Script To Display Modified Date&time Of Files?

May 31, 2010

I am using the following script to creates list of accessed files.I like to add modified date and time of accessed files in the output.

For this what needs to be added in the below script??

#!/bin/bash
#
# creates list of accessed files
#
set $(date)
find /hdc160GB/programmers/projects -cmin -1440 > /hdc160GB/programmers/data/fileschanged/alert_$6-$2-$3.txt

View 7 Replies View Related

Programming :: Awk Multiple Column Into Single Column?

Jul 15, 2010

I have a multicolumn datas, like

a1 b1 ... f1
a2 b2 ... f2
. . ... .

[code]...

I would like to make a file with all these data in one column, like

a1
a2
.
.

[code]....

Can it be done with awk or some other command? Also, is it possible then do add another column in front of this one with numbers of the lines (for every previous column), like

1 a1
2 a2
. .
. .

[code].....

View 14 Replies View Related

Programming :: Copy String A To String B And Change String B With Toupper() And Count The Chars?

Oct 22, 2010

copy string a to string b and change string b with toupper() and count the chars

View 3 Replies View Related

General :: Replace String With Empty String Of Dir Path ?

Apr 2, 2011

I want to replace a string of directory path in a string to empty:

Code:

But this doesnt seem to give me the desired thing:

Code:

This gives the desired outcome, but its specific, i need a variable in the sed not a string. And if I replace STRING="/mnt/sda1/record/$dd/" then I cant use it for something else, cause its has all the weird backslashes now.

View 3 Replies View Related

Programming :: Why Does Strptime (c++) Seem To Not Correctly Parse Date/time String

Feb 8, 2010

here is the problem code using strptime() function.

==================
#include <stdio.h>
#include <string.h>
#include <time.h>

[code]....

Why are the Month and Year so messed up? I am using strptime() according to the man page.

View 2 Replies View Related

General :: Sorting A File With A Variable Name?

Jun 27, 2011

I am trying to sort a file, so I can compare it to another file later. I am storing the file name in a variable called curMo. I then call sort $curMo and it hangs for a very long time and I have to quit the process. why this is not working or how to make it work?

Here is part of my code:

#sort this file for this Location
sort -u $curMo -o $curMo.sorted

View 1 Replies View Related

General :: Sorting Files In A Directory?

Jan 6, 2010

I have some files in a directory like

file1.txt
file10.txt
file2.txt

[code]...

View 5 Replies View Related

General :: Extract A String Within A String Using A Pattern?

Nov 4, 2010

i have a file name using the following pattern:

PREFIX: AR
SOURCE: LEGACY
DATETIME: YYYYMMDD_HH24MISS
SUFFIX: .txt

sample filename:AR_LEGACY_20101104_105500.txti want to extract the source which is LEGACY in this case. how do i do this using shell?

View 1 Replies View Related

General :: How To Refresh Htop After Sorting (via Shift+m)

Jun 22, 2011

I love using htop, but I have noticed that whenever I sort by a parameter (for example, Shift+m for sorting by Memory usage), the htop stats stop dynamically refreshing. Is this intended? I also notice this with top as well.

View 1 Replies View Related

General :: Sorting In Aggregate Rather Than Tree Fashion With 'ls -Rt'?

Apr 28, 2010

The command: Code: ls -lRt Shows a recusrive listing, and sorts by modification time. But this in in tree fashion, where it first lists the contents of the current folder sorted by time, and then the contents of each child folder sorted by time. How would one accomplish this type of sort, but with an aggregate listing - all items recursively sorted together, rather than by individual folder?

View 3 Replies View Related

General :: Sorting In Vi Editor & Copying To Clipboard

May 6, 2010

(1)There should be a command to send content to clipboard instead of 36 buffers available in vi just like ':set paste' allows pasting from clipboard inside vi using ctrl+shift+v in insert mode.(Currently I select area using mouse & right click then copy )


2)Let us say I have sentence "I am young" I want to arrange the words in this line in alphabetical order so that I get 'am I young'. First I thought replacing space by in sentence.Then !#j then type sort -n where # represents number of words.Then #J to join the filteredlines.It works but now I have file with hundreds of sentence of varying length.If I make a macro how will it know the number of words?

View 9 Replies View Related

General :: Include Special Characters When Sorting Files By Name (Fedora 12 I386)?

Feb 15, 2010

I am dragging my files over to a new Fedora 12 installation and I just noticed that special characters are not taken into account when sorting files by name (I want '_js' to come before 'images').Is there a way to make the sorting process behave like Windows, where files starting with a special character are listed first?

View 5 Replies View Related

General :: String Replace In Filenames - Files Already Contain The String "Soundtrack"

Jun 11, 2011

Moving right along, I have a folder of MP3 files containing various Movie sound tracks and scores. I'm using Audio Tag Tool to tag all the files at once with an "Artist" of "Soundtrack", and to inherit the "Title" tag from the file name. After that, I will rename all the files (Using Audio Tag Tool -- awesome program, btw) with the format "<Artist> - <Title>.mp3"

The problem, is many of my files already contain the string "Soundtrack", which would be redundant. I happen to be a perfectionist, so I'm unable to ignore it and move on. Hence my question to you fine folk: I want to delete all instances of "soundtrack" (-i case irrelevant) in the filenames before I go through the above steps. But, its not quite that simple. This is a sample of some of the file names:

[Code]....

View 3 Replies View Related

CentOS 5 :: Time Display Is 12 Hours Out?

Apr 11, 2009

I have the bar at the top configured to display the time but it is displaying 12 hours out.For example, it's now 16:49 but the time is displaying as 06:49. If I click on Adjust Date & Time it has the correct time in there and it is configured to display 24-hour format and is in the correct time zone. If I switch to 12-hour format it displays 6:49 AM which is clearly incorrect.I can't fix it because it thinks the time is correct when I try to change it.

View 4 Replies View Related

General :: Insert Column With Awk / Sed Between Two?

Jan 18, 2011

I have a two column file and I need to create a new column in between the first and second but the new column adds a value to the first. E.g.code...

I thought I had figured out how to do it with the following but it just hangs:

awk -F '{print $0,$0+25,$1}' file_in > file_out

Also tried the following to no avail:

awk -F,-v OFS,'{print $0,$0+25,$1}' file_in > file_out

I can add the new column with the added value to the last column easy ( awk '{print $0,$0+25}' file_in > file_out).

View 8 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved