Sponsored Content
Top Forums Shell Programming and Scripting Sort by id value in every two rows Post 303035770 by Chubler_XL on Sunday 2nd of June 2019 06:58:24 PM
Old 06-02-2019
You were very close with your awk, sort, cut pipeline:

Code:
awk -F\" 'NR%2{printf "%s\t%s\t",$2,$0; next }1' mydata |
  sort -n | cut -f2- | tr '\t' '\n'

This User Gave Thanks to Chubler_XL For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Sort, group rows

I wrote script in bash which generates this report: User1,admin,rep,User2,shell,path1,x1,r1 User2,admin,rep,User7,shell,path1,x1,r1 User3,admin,rep,User4,shell,path1,x1,r1 User4,admin,rep,User3,shell,path1,x1,r1 User5,admin,rep,User1,shell,path1,x1,r1 User6,admin,rep,User5,shell,path1,x1,r1... (6 Replies)
Discussion started by: patrykxes
6 Replies

2. Shell Programming and Scripting

Deleting specific rows in large files having rows greater than 100000

Hi Guys, I need help in modifying a large text file containing more than 1-2 lakh rows of data using unix commands. I am quite new to the unix language the text file contains data in a pipe delimited format sdfsdfs sdfsdfsd START_ROW sdfsd|sdfsdfsd|sdfsdfasdf|sdfsadf|sdfasdf... (9 Replies)
Discussion started by: manish2009
9 Replies

3. Shell Programming and Scripting

Sort the multi column rows

abc xyz - - - - - - - - - - - How to sort the second column in ascending order. (2 Replies)
Discussion started by: sandy1028
2 Replies

4. Shell Programming and Scripting

Split single rows to multiple rows ..

Hi pls help me out to short out this problem rm PAB113_011.out rm: PAB113_011.out: override protection 644 (yes/no)? n If i give y it remove the file. But i added the rm command as a part of ksh file and i tried to remove the file. Its not removing and the the file prompting as... (7 Replies)
Discussion started by: sri_aue
7 Replies

5. UNIX for Advanced & Expert Users

Script to sort the files and append the extension .sort to the sorted version of the file

Hello all - I am to this forum and fairly new in learning unix and finding some difficulty in preparing a small shell script. I am trying to make script to sort all the files given by user as input (either the exact full name of the file or say the files matching the criteria like all files... (3 Replies)
Discussion started by: pankaj80
3 Replies

6. UNIX for Dummies Questions & Answers

merging rows into new file based on rows and first column

I have 2 files, file01= 7 columns, row unknown (but few) file02= 7 columns, row unknown (but many) now I want to create an output with the first field that is shared in both of them and then subtract the results from the rest of the fields and print there e.g. file 01 James|0|50|25|10|50|30... (1 Reply)
Discussion started by: A-V
1 Replies

7. Shell Programming and Scripting

Sort help: How to sort collected 'file list' by date stamp :

Hi Experts, I have a filelist collected from another server , now want to sort the output using date/time stamp filed. - Filed 6, 7,8 are showing the date/time/stamp. Here is the input: #---------------------------------------------------------------------- -rw------- 1 root ... (3 Replies)
Discussion started by: rveri
3 Replies

8. UNIX for Dummies Questions & Answers

Converting Columns To Rows Sort Of

Hi I'm a UNIX awk and sed novice at best. I'm trying to creat a .csv file so it can be graphed in Excel. Tried various xargs, awk, sed and paste but just can't seem to get the data to line up. Not sure if this is beyond for a question in these forums. Any help would greatly be appreciated. Have... (4 Replies)
Discussion started by: jimmyf
4 Replies

9. Shell Programming and Scripting

Moving or copying first rows and last rows into another file

Hi I would like to move the first 1000 rows of my file into an output file and then move the last 1000 rows into another output file. Any help would be great Thanks (6 Replies)
Discussion started by: kylle345
6 Replies

10. UNIX for Dummies Questions & Answers

Sort tab delimited file according to which rows have missing values

Hello! I have a tab delimited file with values in three columns. Some values occur in all three columns, other values are present in only one or two columns. I would like to sort the file so that rows with no missing values come first, rows with one missing values come next, and rows with two... (9 Replies)
Discussion started by: MBarrett1213
9 Replies
Cz::Sort(3pm)						User Contributed Perl Documentation					     Cz::Sort(3pm)

NAME
Cz::Sort - Czech sort SYNOPSIS
use Cz::Sort; my $result = czcmp("_x j&a", "_&p"); my @sorted = czsort qw(plachta plaoka Planieka planieka plani); print "@sorted "; DESCRIPTION
Implements czech sorting conventions, indepentent on current locales in effect, which are often bad. Does the four-pass sort. The idea and the base of the conversion table comes from Petr Olsak's program csr and the code is as compliant with CSN 97 6030 as possible. The basic function provided by this module, is czcmp. If compares two scalars and returns the (-1, 0, 1) result. The function can be called directly, like my $result = czcmp("_x j&a", "_&p"); But for convenience and also because of compatibility with older versions, there is a function czsort. It works on list of strings and returns that list, hmm, sorted. The function is defined simply like sub czsort { sort { czcmp($a, $b); } @_; } standard use of user's function in sort. Hashes would be simply sorted @sorted = sort { czcmp($hash{$a}, $hash{$b}) } keys %hash; Both czcmp and czsort are exported into caller's namespace by default, as well as cscmp and cssort that are just aliases. This module comes with encoding table prepared for ISO-8859-2 (Latin-2) encoding. If your data come in different one, you might want to check the module Cstocs which can be used for reencoding of the list's data prior to calling czsort, or reencode this module to fit your needs. VERSION
0.68 SEE ALSO
perl(1), Cz::Cstocs(3). AUTHOR
(c) 1997--2000 Jan Pazdziora <adelton@fi.muni.cz>, http://www.fi.muni.cz/~adelton/ at Faculty of Informatics, Masaryk University, Brno perl v5.10.1 2000-05-16 Cz::Sort(3pm)
All times are GMT -4. The time now is 02:24 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy