Sponsored Content
Full Discussion: Sort command question
Top Forums UNIX for Dummies Questions & Answers Sort command question Post 302842525 by newbie2010 on Friday 9th of August 2013 12:01:35 PM
Old 08-09-2013
Sort command question

I have a file like this:

Code:
/vol/eng_app_0103z
/vol/eng_app_0103z
/vol/eng_app_0120z
/vol/eng_app_0126z
/vol/eng_app_0144z
/vol/eng_app_0150z
/vol/eng_app_0154z
/vol/eng_app_01551z
/vol/eng_app_01552z
/vol/eng_app_0155z
/vol/eng_app_0164z
/vol/eng_app_0199z

When I use the sort command (sort I cannot get the /vol/eng_app_01551z and the /vol/eng_app_01552z to go after the /vol/eng_app_0155z. However, if I delete the z from the paths, I get this file when I use sort, which is what I want except that now the z is gone:

Code:
cat filezx |sort -k 2,2
/vol/eng_app_0103
/vol/eng_app_0103
/vol/eng_app_0120
/vol/eng_app_0126
/vol/eng_app_0144
/vol/eng_app_0150
/vol/eng_app_0154
/vol/eng_app_0155
/vol/eng_app_01551
/vol/eng_app_01552
/vol/eng_app_0164
/vol/eng_app_0199

Is there anyway to get this without using sed or vi to remove all the zs from the file; I'd like the letter z to stay in the paths? Will the sort command strip off the last character if given the right options? I have been trying different combinations but I am not sure how it works as I probably would need to use sort "-" as I have also an underscore. Then I am not sure how it would count the last character.

This is my desired output:

Code:
/vol/eng_app_0103z
/vol/eng_app_0103z
/vol/eng_app_0120z
/vol/eng_app_0126z
/vol/eng_app_0144z
/vol/eng_app_0150z
/vol/eng_app_0154z
/vol/eng_app_0155z
/vol/eng_app_01551z
/vol/eng_app_01552z
/vol/eng_app_0164z
/vol/eng_app_0199z

Anybody use sort a lot might know if this can be done?
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Sort Question

M 47 HIS:LOT 32 DUTY 2 MIKE, FINISHED MIKE ACTIVE STATUS 23TASK YES GOOD 100TASK NO GOOD ======================================== M 47 HIS:LOT 1 DUTY 1 MIKE, FINISHED MIKE ACTIVE STATUS 23TASK YES GOOD ... (7 Replies)
Discussion started by: bobo
7 Replies

2. UNIX for Dummies Questions & Answers

SORT question

I'm looking for a sort command that will sort by zip code first then by last name. (zip code is the last field, last name is first field) data file looks like this. Hope Bob 1234 Main ST. Colorado Springs, CO 80920 I was thinking along the lines of: sort -k9n address.data //for the... (2 Replies)
Discussion started by: ssgatbliss
2 Replies

3. Shell Programming and Scripting

sort question

Hi all. Is there a way that I can use the sort command too sort the following field by earliest time (12:00AM) to latest time (11:59PM)? 07:12PM 07:53PM 07:54PM 08:07PM 10:15AM 10:21AM TIA!!!!!! (1 Reply)
Discussion started by: lyoncc
1 Replies

4. Shell Programming and Scripting

sort question

Hi all. HPUX - posix shell - script question Here's my data: f1 f2 f3 f4 f5 f6 |02/12/09|12:33PM|3|Oceanview |OVT #1| VISA/MC |02/12/09|12:14PM|3|Oceanview |OVT #1| VISA/MC |02/12/09|09:13AM|4|Oceanview |OVT #1| VISA/MC ... (8 Replies)
Discussion started by: lyoncc
8 Replies

5. Shell Programming and Scripting

How to Sort Floating Numbers Using the Sort Command?

Hi to all. I'm trying to sort this with the Unix command sort. user1:12345678:3.5:2.5:8:1:2:3 user2:12345679:4.5:3.5:8:1:3:2 user3:12345687:5.5:2.5:6:1:3:2 user4:12345670:5.5:2.5:5:3:2:1 user5:12345671:2.5:5.5:7:2:3:1 I need to get this: user3:12345687:5.5:2.5:6:1:3:2... (7 Replies)
Discussion started by: daniel.gbaena
7 Replies

6. Shell Programming and Scripting

Is it Possible to sort a list of hexadecimal numbers using "sort" command?

Hello Everybody :) !!!. i have question in mind, is it possible to sort a list of hexadecimal numbers using "sort" command? (9 Replies)
Discussion started by: Kesavan
9 Replies

7. UNIX for Dummies Questions & Answers

New to Unix command line and have a question about the "sort" command

I am going through the Unix Made Easy second edition book by John Muster. So far it's been very informative and I can tell it may be a bit out of date. In one of the exercises it talks about the "sort" command and using it to sort column's of data etc. The "sort" command has changed a bit and... (1 Reply)
Discussion started by: budfoxcat
1 Replies

8. Shell Programming and Scripting

Sort question.

Hi Guys, I have a file to be sorted and uniq with the following format. S00001002|01|20021231 S00001002|01|20011031 S00001006|01|20120430 S00001006|01|20111231 S00001006|01|20111031 S00001006|01|20110831 S00001006|01|20110731 S00001006|01|20101231 S00001006|01|20091231... (5 Replies)
Discussion started by: nua7
5 Replies

9. Shell Programming and Scripting

Sort command question

I have a question about what the sort command is doing. Here is some sample data: 348201310013RVE 2 600201310013GFJ 70 3302013020101NS 40 600201309013GFJ 70 The sort command that is running is as follows: sort -k 1,3 -k 12,4 input.txt > output.txt ... (6 Replies)
Discussion started by: Drenhead
6 Replies

10. UNIX for Beginners Questions & Answers

Sort question

Have a text file containing 4 columns, the 4th column is sorted numerically in descending order. The 2nd column is alpha text. Been able to get the 4th column to sort in descending order. The 2nd column sorts correctly but it's also in reverse. Would like to be able to keep the 4th column sort... (8 Replies)
Discussion started by: jimmyf
8 Replies
mlib_VolumeRayCast_General(3MLIB)			    mediaLib Library Functions				 mlib_VolumeRayCast_General(3MLIB)

NAME
mlib_VolumeRayCast_General, mlib_VolumeRayCast_General_Parallel_Nearest_U8_Bit, mlib_VolumeRayCast_General_Parallel_Nearest_U8_U8, mlib_VolumeRayCast_General_Parallel_Nearest_S16_S16, mlib_VolumeRayCast_General_Parallel_Trilinear_U8_U8, mlib_VolumeRayCast_General_Paral- lel_Trilinear_S16_S16, mlib_VolumeRayCast_General_Divergent_Nearest_U8_Bit, mlib_VolumeRayCast_General_Divergent_Nearest_U8_U8, mlib_Vol- umeRayCast_General_Divergent_Nearest_S16_S16, mlib_VolumeRayCast_General_Divergent_Trilinear_U8_U8, mlib_VolumeRayCast_General_Diver- gent_Trilinear_S16_S16 - cast a ray (or rays) through a 3D data set SYNOPSIS
cc [ flag... ] file... -lmlib [ library... ] #include <mlib.h> mlib_status mlib_VolumeRayCast_General_Parallel_Nearest_U8_Bit( mlib_rays *rays, const mlib_genvolume *vol, void *buffer); mlib_status mlib_VolumeRayCast_General_Parallel_Nearest_U8_U8( mlib_rays *rays, const mlib_genvolume *vol, void *buffer); mlib_status mlib_VolumeRayCast_General_Parallel_Nearest_S16_S16( mlib_rays *rays, const mlib_genvolume *vol, void *buffer); mlib_status mlib_VolumeRayCast_General_Parallel_Trilinear_U8_U8( mlib_rays *rays, const mlib_genvolume *vol, void *buffer); mlib_status mlib_VolumeRayCast_General_Parallel_Trilinear_S16_S16( mlib_rays *rays, const mlib_genvolume *vol, void *buffer); mlib_status mlib_VolumeRayCast_General_Divergent_Nearest_U8_Bit( mlib_rays *rays, const mlib_genvolume *vol, void *buffer); mlib_status mlib_VolumeRayCast_General_Divergent_Nearest_U8_U8( mlib_rays *rays, const mlib_genvolume *vol, void *buffer); mlib_status mlib_VolumeRayCast_General_Divergent_Nearest_S16_S16( mlib_rays *rays, const mlib_genvolume *vol, void *buffer); mlib_status mlib_VolumeRayCast_General_Divergent_Trilinear_U8_U8( mlib_rays *rays, const mlib_genvolume *vol, void *buffer); mlib_status mlib_VolumeRayCast_General_Divergent_Trilinear_S16_S16( mlib_rays *rays, const mlib_genvolume *vol, void *buffer); DESCRIPTION
Each of these functions casts a ray (or rays) through a three-dimensional(3D) data set, then computes and returns the interpolated samples at each step along the way. In trilinear interpolation, the value at point P is computed from its eight surrounding neighbors based on the equation below. P = (1-a)*(1-b)*(1-c)*P0 + a*(1-b)*(1-c)*Px + (1-a)*b*(1-c)*Py + (1-a)*(1-b)*c*Pz + a*b*(1-c)*Pxy + a*(1-b)*c*Pxz + (1-a)*b*c*Pyz + a*b*c*Pxyz where a, b, and c are the fractional parts of the coordinates of point P. The trilinear interpolation is represented by the following figure: Printed copy or docs.sun.com displays a figure that represents the trilinear interpolation. In nearest neighbor operation, the sample value at point P is replaced by the value of the nearest neighbor voxel. PARAMETERS
Each of the functions takes the following arguments: rays Casting rays. vol Volume data that consists of slices. buffer Working buffer. RETURN VALUES
Each of the functions returns MLIB_SUCCESS if successful. Otherwise it returns MLIB_FAILURE. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Interface Stability |Committed | +-----------------------------+-----------------------------+ |MT-Level |MT-Safe | +-----------------------------+-----------------------------+ SEE ALSO
mlib_VolumeRayCast_Blocked(3MLIB), attributes(5) SunOS 5.11 2 Mar 2007 mlib_VolumeRayCast_General(3MLIB)
All times are GMT -4. The time now is 02:37 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy