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


ADVERTISEMENT

General :: Sort .txt File By The Numerical Order Of Column?

Mar 22, 2010

I have this .txt file

3183630 R
3574216 W
5264994 M
2656889 A

I want to sort it by the numerical order of column. After sort, I wish to get output like

2656889 A
3183630 R
3574216 W
5264994 M

anyone knows how to use sort to do that? or any other command?

View 6 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

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 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

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 :: File Name In Separate Column?

Apr 26, 2010

I have some series of files, which actually named bellow

<day_month_yr>_<hh:mm:ss>.<host_name>.<IP.ip.ip.ip>.<log_name>.txt

I want to show this file name below the column may be

Date Time Host_Name IP_address Login_Name
----- ---- --------- ---------- ----------
<day_month_yr> <hh:mm:ss> host_name x.x.x.x log_name
...

View 5 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 :: Extract 5th Column From A File Without The Header?

Oct 15, 2010

How can I extract 5th column from a file without the header.

View 5 Replies View Related

General :: How To Redirect The Output To Different Column In .csv File?

Apr 25, 2011

I was trying to redirect the output of two variables to different columns of a .csv file in MS excel like this,

Code:
echo "$a $b" > abc.csv
But I am getting both $a and $b in the same column, is there anything I can use instead of to move the value of $b to the next column? Or is there a good different approach to do it?

View 2 Replies View Related

General :: Text File Column Editing

Jul 17, 2011

I have 2 large text files , one looks like this:

<contact type="1">blahblah@hotmail.com</contact>
<contact type="1">blahblah2@hotmail.com</contact>
<contact type="1">blahblah3@hotmail.com</contact>

The other is a list of emails in single column format like this:

emailaddy@hotmail.com
emailaddy2@hotmail.com
emailaddy3@hotmail.com , etc

Is there a command to delete all the blahblah emails from text file 1 and replace them with the ones from text file 2?

Or maybe a linux version of 'Csved' which has the ability to add,remove,insert columns?

View 5 Replies View Related

General :: Recreating A Column Byte-based File?

Nov 5, 2009

I have a file that stores employee login IDs, names, types, and permissions. Our software reads the information based on byte-columns, so it reads a column as any ASCII character (spaces, letters, numbers, punctuation, etc.). I want to create a web-interface for adding and removing users, and storing the data in a MySQL database. However, if I am creating the files from the MySQL output, I need a way to write to specific column locations in the file ...

User ID: Columns 1-4
User Name: Columns 6-30
Type: 32-40
Permissions: 42-45

I want to use a scripting language, preferably C-Shell, to call MySQL for the data and write the data to the correct columns of the file. I wrote a script that takes the data from the file, and dumps it into the MySQL table, so maybe I can pad the remaining space in the table column to fill with spaces ...

View 12 Replies View Related

General :: Check Quality Of A Specific Column In A Tab-delimited File?

Mar 8, 2010

shell commands for such two goals?

In a tab-delimited file,

Code:
1aIa11aa
2bIIa22aa
1cIIIaabcaa
4dIVaabcaa

1. How can I find the non-unique values in the 1st column (1, in this case)?

2. How can I find the non-integer values in the 5th column (abc, in this case)?

View 3 Replies View Related

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

Programming :: Sorting A Dictionary File?

Nov 1, 2010

I have this dictionary file that has this format:

SUBSTITUTE_VALUE, Real Value
SUBSTITUTE_VALUE_2, Real Big Value
SUBSTITUTE_VALUE_HECL, Hardware Abstract
SUBSTITUTE_V, Valley Mem

I want to sort this file so the LONGEST Substitute Values are listed at the top ( so SUBSTITUTE_VALUE_HECL would be first in the list). Obviously I want to keep the related values tagging along with them, so the whole first line would be
SUBSTITUTE_VALUE_HECL, Hardware Abstract

Playing with sort This has me pretty close: sort dict.file -k1.1n,1

View 2 Replies View Related

General :: Numerical Encoding Of Text, By Position?

Apr 26, 2010

I have a file of words and want to encode them in a numeric form, based on position.This is best explained by example:
PEOPLE ==> 123152

Reading left to right:
P was first encountered at position 1 so it is encoded as 1.
E was first encountered at position 2 so it is encoded as 2.

[code]...

View 5 Replies View Related

Programming :: Sorting Specific Values From An XML File

Sep 21, 2010

I need a shell script which gathers the data from a remote XML file and then displays it according to my needs.. I need this for my job due to the fact that I need to keep track price changes of euro, usd, gold, etc. The XML file I am talking about is located at this page: here. The reason I am posting the URL is that I need to use curl to get this file and it does NOT have newlines after each tag. I thought that that would be a problem. Here is what I need from the script: 1) curl to get the page 2) make use of sed, awk, etc. to display its contents in a more structured and readable manner as shown below:

A: 64.125 (% -0.26)
B: 81.130 (% -0.32)
C: 1.4930 (% 0.00)
D: 1.9590 (% 0.36)

View 5 Replies View Related

General :: Warning Messages And Numerical Recipes Functions In C?

Jun 19, 2010

I am using some "Numerical Recipes in C" routines in my C code.(I am using ludcmp() & lubksb().)These are used to find inverse of a matrix.After compiling my c code, I get following warning messages.I have not understood them at all. What is the meaning of these and why did they pop up and how to remove them?

Code:
nrutil.h:11: warning: 'sqrarg' defined but not used
nrutil.h:14: warning: 'dsqrarg' defined but not used

[code]....

View 7 Replies View Related

Ubuntu :: Tweaking Nautilus' File Sorting Order?

Dec 31, 2010

I've recently switched from Windows to Ubuntu and have a question regarding tweaking the character order Nautilus uses for alphabetical sorting. In my music/graphics/etc folder hierarchies, I have used a hyphen at the start as a 'hack' to 'sticky' some folders above the rest for quicker access. This worked fine in Windows, but Nautilus ignores a hyphen in it's sorting calculations. Is there anyway, simple or complex to replicate this behaviour in Nautilus?

View 4 Replies View Related

General :: Count The Numerical Digits In Between The Text Using A Command Or A Script?

Jan 1, 2010

I want to count the digits in between the text in a file.

e.g.

write down the form

2.3 3.3 3.0 505.0 0.777E-07

22.3 3.3 5.0 503.0 1.777E-04

Then read this.

How can i do the counting of these digits present in between a text in a file?

View 9 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

Software :: Swap The First And Second Column In A File?

Feb 3, 2011

I have a file in the following format

item1 item2 attrbute1, attribute2, line1
item1 item2 attrbute1, attribute2, line2
item1 item2 attrbute1, attribute2, line3
item1 item2 attrbute1, attribute2, line4
item1 item2 attrbute1, attribute2, line5

Question: what command can I use swap item1 and item2 around and keep the attributes in place.
A space seperates the first and second column. The file has many hundreds of lines in which these need to be swapped

Output needs to be as follows:

item2 item1 attrbute1, attribute2, line1
item2 item1 attrbute1, attribute2, line2
item2 item1 attrbute1, attribute2, line3

View 3 Replies View Related

Programming :: Bash Awk Column To End Of File?

Sep 4, 2010

Code:

#!/bin/bash
ls -lhGg | while read line; do echo "$line"; done | awk ' { print $3" "$6 } '

what i want to do is be able to print column 3 and every column greater then 5. Has to be to the end of the line, since different filenames can have different amounts of words in them and the blank space is the separator. my current code works just fine if the file has no blank space.

View 8 Replies View Related

Programming :: Add A Column To A Text File?

Apr 28, 2011

I have a text field that is just list of servers and I need to add the word hostname in front of them... It must be brain fart but I can't think of how to do this. Basically I need this:

server1
server2
server3

To this:

hostname server1
hostname server2
hostname server3

(And I just mean simply the word "hostname")

View 2 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

Programming :: Script To Read A File And Get Each Column With Varibles?

Jul 2, 2010

i have a script to read a file and get each column with varibles.actually my file: hplog1 sample 3 lines consists of

client1_day- 2010
jan
client2 2009

[code]....

View 1 Replies View Related

Software :: Finding The Right File With Only A Line And Column Number?

Aug 1, 2011

I tried to come up with a thread title that was specific without being too long or cryptic. Don't think I succeeded. In my PHP error log I keep getting this error over and over again:

Code:

EntityRef: expecting ';' at line 565, column 81

It's very odd to me that it doesn't contain any sort of stack trace or file info. I know which of my virtual hosts and therefore which directory it's coming from, and it's happened now on half a dozen different servers that this site has lived on. So obviously I'm trying to track it down and add the missing ';' to the right file. This directory has dozens of sub-directories and hundreds of files though.

This is the best I've managed to come up with so far:

Code:

find . -type f -iname "*.php" -print -exec awk 'NR==565' {} ;
(I've run it both with and without the -iname filter.)

I get a very large list of files, and some of them display the contents of line 565 after them. I've checked through a number of them there, but haven't found the culprit. Is it possible to limit my "find" command to only files that have at least 565 lines? Is it possible to have it only print matches from line 565 that has at least 81 columns? How would I modify that to print perhaps 5 lines on either side (in case the error reporting is pulling a slightly different line.)

View 3 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







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