Sponsored Content
Top Forums Shell Programming and Scripting Sorting a flat file based on multiple colums(using character position) Post 302081323 by vish_indian on Monday 24th of July 2006 01:15:37 PM
Old 07-24-2006
Quote:
In general, how to sort(order by) multiple columns?
sort -k 1,3 is doing just that. eg, for input
Faroe Island 20 island
japan 19 test
japan 19 airline
Alpha Zulu 21 island
Alpha 121 island

Japan occurs twice in first column, so while sorting, 3rd column is considered and the output is:

Alpha 121 island
Alpha Zulu 21 island
Faroe Island 20 island
japan 19 airline
japan 19 test

isn't that what you wanted?
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to insert at a particular position in flat file

Hi All, I have a flat file with ~ as de-limiter (e.g: aaa~ba a~caa~0~d~e) What I want is check if the 4th character is 0 and replace it with say 4. So now it becomes : aaa~ba a~caa~4~d~e. I have to do this for the whole file, but the delimiter position remains the same, not the... (10 Replies)
Discussion started by: akdwivedi
10 Replies

2. Shell Programming and Scripting

Convert case on specified position of flat file

Please help Need a script which will do the following : Search on fixed width file , go to position (25,2) which means 25th and 26th position, Find if there are any char in lower case: For example 25,2 can be (9T) or (9w) or (Ww) or (wW)....The two positions can be numeric or alpha...no... (13 Replies)
Discussion started by: ssantoshss
13 Replies

3. Shell Programming and Scripting

Sorting the records in the Flat file

Hi all, I am using this command "sort -d -u -k1 IMSTEST.74E -o tmp.txt" to the records in the flat. Can any tell me how to sort the file except first line in the file For ex: i/p First line: DXYZ Second line : jumy third : cmhk fourth : andy Output should... (5 Replies)
Discussion started by: sudhir_barker
5 Replies

4. Shell Programming and Scripting

Cut multiple data based on character position

How to extract multiple data based on character position. I need to fetch from 7-9 and 22-26 and there is no delimiter for 22-26 since it is part of the column. The file may have more than 1000 character long.I managed to pull any one but not both for example test data 12345 zxc vbnmlk... (1 Reply)
Discussion started by: zooby
1 Replies

5. Shell Programming and Scripting

Read from Multiple character delimited flat file

Hello Guys I have a multiple character delimited flat file "|~|". when I tried to read the data the "|" character also coming Example I/P file 9882590|~|20111207|~|K03501000063005574033961|~|K|~| Command to get the second column I used awk -F"|~|" ' {print $2}' ... (2 Replies)
Discussion started by: Pratik4891
2 Replies

6. Shell Programming and Scripting

Find the position of a field/column in a flat file

Hi, Let say I have a file which has around 400 fields. SampleFile ========= PATIENTID|FACILITY|................|TIME_LAST_VISITED_BY_MD|.....|STATUS| How is it possible to find out which field is TIME_LAST_VISITED_BY_MD?fro example by seeing the above structure we can saw FACILITY... (5 Replies)
Discussion started by: machomaddy
5 Replies

7. Linux

Linux script to remove a character in a file based on position.

Greetings, We have a requirement where we need to loop in a fixed width file in linux and remove a character based on a position for every record. It would highly appreciate if someone can help to automate this. Appreciate your time and help! Regards (3 Replies)
Discussion started by: mailme0205
3 Replies

8. Shell Programming and Scripting

Find position of character in multiple strings in a file

Greetings. I have a file with information like this: AMNDHRKEOEU?AMNDHRKEOEU?AMNDHRKEOEU?AMNDHRKEOEU? AMNDHRKEEU?AMNDHREOEU? AMNDHREU?AHRKEOEU?AMNDHRKEU?AMNDKEOEU? What I need to extract is the position, in every line, of every occurrence of '?' A desired output would be something... (6 Replies)
Discussion started by: Twinklefingers
6 Replies

9. UNIX for Dummies Questions & Answers

Change a character based on its position number

Hi I have a text file that I want to change some of the characters based on their position. My file contain multiple lines and characters should be counted continuously line by line. For example, I want to convert the 150th T to C. What can I do? Here is a portion of my file:... (10 Replies)
Discussion started by: a_bahreini
10 Replies

10. Shell Programming and Scripting

Splitting based on occurence of a Character at fixed position

I have a requirement where i need to split a file based on occurence of a character which is present at a fixed position. Description is as below: 1. The file will be more than 1 Lakh records. 2. Each line will be of fixed length of 987 characters. 3. At position 28 in each line either 'C' or... (9 Replies)
Discussion started by: Neelkanth
9 Replies
GRDLANDMASK(l)															    GRDLANDMASK(l)

NAME
grdlandmask - Create "wet-dry" mask grdfile from shoreline data base. SYNOPSIS
grdlandmask -Gmask_grd_file] -Ixinc[m|c][/yinc[m|c]] -Rwest/east/south/north[r] [ -Amin_area[/min_level/max_level] ] [ -Dresolution ] [ -F ] [ -Nmaskvalues[o] ] [ -V ] DESCRIPTION
grdlandmask reads the selected shoreline database and uses that information to decide which nodes in the specified grid are over land or over water. The nodes defined by the selected region and lattice spacing will be set according to one of two criteria:(1) Lands vs water, or(2) the more detailed (hierarchial) ocean vs land vs lake vs island vs pond. The resulting mask grdfile may be used in subsequent opera- tions involving grdmath to mask out data from land [or water] areas. -G Name of resulting output mask grd file. -I x_inc [and optionally y_inc] is the grid spacing. Append m to indicate minutes or c to indicate seconds. -R west, east, south, and north specify the Region of interest. To specify boundaries in degrees and minutes [and seconds], use the dd:mm[:ss] format. Append r if lower left and upper right map coordinates are given instead of wesn. OPTIONS
-A Features with an area smaller than min_area in km^2 or of hierarchical level that is lower than min_level or higher than max_level will be ignored [Default is 0/4 (all features)]. See DATABASE INFORMATION in the pscoast man-pages for more details. -D Selects the resolution of the data set to use ((f)ull, (h)igh, (i)ntermediate, (l)ow, or (c)rude). The resolution drops off by ~80% between data sets. [Default is l]. Note that because the coastlines differ in details a node in a mask file using one resolution is not guaranteed to remain inside [or outside] when a different resolution is selected. -F Force pixel registration. [Default is grid registration]. -N Sets the values that will be assigned to nodes. Values can be any number, including the textstring NaN. Append o to let nodes exactly on feature boundaries be considered outside [Default is inside]. Specify this information using 1 of 2 formats: -Nwet/dry. -Nocean/land/lake/island/pond. [Default is 0/1/0/1/0 (i.e., 0/1)]. -V Selects verbose mode, which will send progress reports to stderr [Default runs "silently"]. EXAMPLES
To set all nodes on land to NaN, and nodes over water to 1, using the high resolution data set, do grdlandmask -R-60/-40/-40/-30 -Dh -I5m -N1/NaN -Gland_mask.grd -V To make a 1x1 degree global grid with the hierarchical levels of the nodes based on the low resolution data, try grdlandmask -R0/360/-90/90 -Dl -I1 -N0/1/2/3/4 -Glevels.grd -V SEE ALSO
gmt(1gmt), grdmath(1gmt), grdclip(1gmt), psmask(1gmt), psclip(1gmt), pscoast(1gmt) 1 Jan 2004 GRDLANDMASK(l)
All times are GMT -4. The time now is 12:39 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy