Sponsored Content
Top Forums Shell Programming and Scripting Sorting problem "sort -k 16,29 sample.txt > output.txt" Post 302082067 by ganapati on Monday 31st of July 2006 04:51:43 AM
Old 07-31-2006
Java Sorting problem "sort -k 16,29 sample.txt > output.txt"

Hi all,

Iam trying to sort the contents of the file based on the position of the file.
Example:

$cat sample.txt
0101020060731 ## Header record
1c1 Berger Awc ANP20070201301 4000.50
1c2 Bose W G ANP20070201609 6000.70
1c2 Andy CK ANP20070201230 28000.00
1c3 Bharg ANP20070201847 9000.80
1c3 Peter Neid ANP20070201109 2000.50
1c3 Ralf Tiger ANP20070201365 4000.10
900006 ## Trailer record

Where ANP*********** is the policy number and starts in the file from 16th position. I need to sort based on these policy numbers.
Iam using the "Sort" Option as below:

sort -k 16,29 sample.txt > output.txt

But it is not sorting based on Policy numbers.
Could any one help me to fix it.

Many Thanks and Regards,
Ganapati Smilie
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Find -name "*.txt" in Korn Shell Script

The following find command works on the Korn Shell command line: find . \( ! -name . -prune \) -type f -name "*.txt" -mtime +100 In the particular directory I'm in, the above find will list correctly the three text files that exist that haven't been modified in over 100 days: ... (3 Replies)
Discussion started by: jwperry
3 Replies

2. UNIX for Dummies Questions & Answers

grep/cat/more -- search in a txt file and display content from a specific "keyword"

Hi, I have a .txt file Sample: ===================== NEXT HOST ===================== AEADBAS001 ip access-list extended BLA_Incoming_Filter ip access-list extended BLA_Outgoing_Filter access-list 1 permit xxxxxxxxxxxxxx access-list 2 permit xxxxxxxxxxxxxx =====================... (4 Replies)
Discussion started by: I-1
4 Replies

3. Shell Programming and Scripting

How to get the output from [ -s "abc.txt" ]

Hi, I am trying to check the file not empty, if its not empty then i try to send other system by ftp, the following codes doesnt work if ] then echo "File ${OUTBOUNDFILE} have data" ftp -i -n -v 204.104.22.33 >> ${FTP_LOGFILE} << EOF user abc def ascii put ${OUTBOUNDFILE} quit EOF... (1 Reply)
Discussion started by: Imran_Chennai
1 Replies

4. UNIX for Dummies Questions & Answers

echo "ABC" > file1.txt file2.txt file3.txt

Hi Guru's, I need to create 3 files with the contents "ABC" using single command. Iam using: echo "ABC" > file1.txt file2.txt file3.txt the above command is not working. pls help me... With Regards / Ganapati (4 Replies)
Discussion started by: ganapati
4 Replies

5. Shell Programming and Scripting

ls -laR | grep "^-" | awk '{print $9}'| grep "$.txt"

Hi, I don't know hot to make this command work: ls -laR | grep "^-" | awk '{print $9}'| grep "$.txt" It should return the list of file .txt It's important to search .txt at the end of the line, becouse some file name have "txt" in their name but have other extensions (13 Replies)
Discussion started by: DNAx86
13 Replies

6. Shell Programming and Scripting

"Time" command and save result in a file.txt

Hi, I'am using "time" to check execution time of some script. Is there any possibility to save time command result into a file ? (2 Replies)
Discussion started by: Physix
2 Replies

7. Shell Programming and Scripting

get rid of "^" character in a .txt file

I have a file that I ran the dos2unix utility on, it cleans up pretty well, but I noticed an occasional ^M leftover, (actual characters) these may or may not be strays from my original dos file. Either way, I want to get rid of the ^ and any character that may follow. ^M ^C or whatever. How do I... (6 Replies)
Discussion started by: ajp7701
6 Replies

8. Homework & Coursework Questions

how to change this looking for mimetype "text/plain" instead of extension *.txt?

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: Create a Shell script that looks for all text files in your home directory (including subdirectories). List... (3 Replies)
Discussion started by: rollinator
3 Replies

9. Shell Programming and Scripting

finding the strings beween 2 characters "/" & "/" in .txt file

Hi all. I have a .txt file that I need to sort it My file is like: 1- 88 chain0 MASTER (FF-TE) FFFF 1962510 /TCK T FD2TQHVTT1 /jtagc/jtag_instreg/updateinstr_reg_1 dff1 (TI,SO) 2- ... (10 Replies)
Discussion started by: Behrouzx77
10 Replies

10. Programming

[Python] replicating "sha256 -C checksum_file.txt file.txt"

Hello everyone, Since my python knowledge is limimted, I've challenged myself to learn as much as possible to help me with my carrere. I'm currently trying to convert a shell script to python, just to give myself a task. There is one section of the script that I'm having issues converting and... (2 Replies)
Discussion started by: da1
2 Replies
SORT-DCTRL(1)						       Debian user's manual						     SORT-DCTRL(1)

NAME
sort-dctrl - sort Debian control files SYNOPSIS
sort-dctrl [options] [ file ... ] sort-dctrl --copying | --help | --version | -ChV DESCRIPTION
The sort-dctrl program sorts Debian control files according to specified criteria. A Debian control (dctrl) file is a semistructured single-table database stored in a machine-parseable text file. Such a database consists of a set of records; each record is a mapping from field names to field content. Textually, records are separated by empty lines, while each field is encoded as one or more nonempty lines inside a record. A field starts with its name, followed by a colon, followed by the field content. The colon must reside on the first line of the field, and the first line must start with no whitespace. Subsequent lines, in contrast, always start with linear whitespace (one or more space or tab characters). The sort-dctrl program recognizes two field types: string fields and version fields. Version fields act also as numeric fields. String fields are compared according to strict lexicographical octet-by-octet comparison, after ignoring any initial whitespace after the colon. Version fields are parsed and compared as Debian version numbers. When comparing version numbers, if a field content does not in fact con- form to the version number syntax, it compares less than any field content that does conform, and equal to any other nonconforming field content. The sort-dctrl program assumes all fields are string fields unless told otherwise. You can specify arbitrary number of keys for sorting, using the -k option. The keys are interpreted in a descending order of priority: the first key specified is primary, the second key specified is secondary, and so on. If two records compare equal under the primary key, then they are compared under the secondary key, and so on. If no keys are specified, a default key is assumed (the "Package" field with no mod- ifiers). OPTIONS
-k keyspec, --key-spec=keyspec Specify one or more keys for sorting. You may specify this option any number of times. The keyspec argument consists of a comma- separated list of key specifications. Each key specification consists of the name of the field that serves as the key, optionally followed by a colon and key modifiers. The following key modifiers are supported: r Invert the comparison for this key, reversing the sorting order. v Treat this field as a version number field. n Treat this field as numeric, which currently is synonymous with v. -q, --quiet, --silent Output nothing to the standard output stream. Instead, exit immediately after finding the first match. -l level, --errorlevel=level Set log level to level. level is one of fatal, important, informational and debug, but the last may not be available, depending on the compile-time options. These categories are given here in order; every message that is emitted when fatal is in effect, will be emitted in the important error level, and so on. The default is important. -V, --version Print out version information. -C, --copying Print out the copyright license. This produces much output; be sure to redirect or pipe it somewhere (such as your favourite pager). -h, --help Print out a help summary. EXAMPLES
Here are some sample invocations of the program: sort-dctrl /var/lib/dpkg/available Output the dpkg available file sorted by the package name. sort-dctrl -k Version:v /var/lib/dpkg/available Output the dpkg available file sorted in ascending order of version numbers. sort-dctrl -k Version:vr /var/lib/dpkg/available Output the dpkg available file sorted in descending order of version numbers. sort-dctrl -k Package,Version:v /var/lib/dpkg/available Output the dpkg available file sorted primarily in ascending order of package names and secondarily in descending order of version numbers. sort-dctrl -k Installed-Size:n,Size:nr /var/lib/dpkg/available Output the dpkg available file sorted primarily in ascending order of installation sizes and secondarily in descending order of package sizes. AUTHOR
The program and this manual page were written by Antti-Juhani Kaijanaho <ajk@debian.org>. SEE ALSO
Debian Policy Manual. Published as the Debian package debian-policy. Also available in the Debian website. grep-dctrl(1) Debian Project 2005-06-08 SORT-DCTRL(1)
All times are GMT -4. The time now is 10:03 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy