Sponsored Content
Top Forums Shell Programming and Scripting Helpless in basic shell sorting Post 302146888 by ashikin_8119 on Thursday 22nd of November 2007 11:54:34 PM
Old 11-23-2007
Helpless in basic shell sorting

Hi all;

I need help in sorting and grouping the data in one flat file.The file look like this:

040171011140820070000000009650244002933170003000000075272
1F921338300506 01082007000014000000027665
1H912279980109 01082007000012000000042420
1S503377200110 01082007000014000000005187
1S503377200110 01082007000688000000005188
3SF98


I need to rearrange the file to become like this:

040171011140820070000000009650244002933170003000000075272 3SF98
1
2S503377200110 01082007000688000000005188
1
2F921338300506 01082007000014000000027665
2S503377200110 01082007000014000000005187
2H912279980109 01082007000012000000042420

The Rules:
i)I need to append the whole line that starts with '3' to first line (that start with 0) -lets say length for first line is 70,so new line start from position 71
ii)i also need to replace fisrt character of '1' to become '2'
iii)and group them according to the position 28 till length 3,'688' will have one group and other than '688' (in this case '012','014' )will be grouped in one group (and need to sort in desc order,means 688 first followed by others)
iv)then i need to add 1 for each new group (excluding line that starts with 0)

i have tried this script (which i get from this forumn also - thx (forget the name) ) and modified a bit:

sort -k2 FileLoad.txt.1 |awk '/^1/{sub(/1/,"2")}!x[substr($0,28,3)]++{print 1}1'

The output become like this:

1
3SFVPVKI349009876
1
040171011140820070000000009650244002933170003000000075272
1
2H912279980109 01082007000012000000042420
1
2S503377200110 01082007000014000000005187
2F921338300506 01082007000014000000027665
1
2S503377200110 01082007000688000000005188


Please help....Tq in advance
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

basic c-shell help

hello, i am very new to this, so i have basic questions about writing a shell. if i am working with a basic file, "main.c" and a shell file, "shell", what will the shell file look like? i want to change the command prompt from % to $, and i want to be able to have standard input from the... (0 Replies)
Discussion started by: ayalex
0 Replies

2. Shell Programming and Scripting

unix shell basic

need some help badly. if i had a file with content of few lines like the followings. 1183724770.651 0.049 137.157.56.169 200 415 GET http://venus/client/clients.xml "text/xml" 1183724770.651 0.049 141.183.101.250 200 415 GET http://venus/client/clients.xml "text/xml" using what command... (1 Reply)
Discussion started by: akagi07
1 Replies

3. Linux

Basic Linux Shell Command

I'm working with telnet under windows and Xming. I connect to a network computer and I open Xterm. With Xterm I want to be able to open more than one windows like firefox, nedit etc. Example : When a open firefox on the xterm, I type "firefox", after that, I cannot make an other command until I... (1 Reply)
Discussion started by: Meccos
1 Replies

4. Shell Programming and Scripting

shell script basic doubt

hi, I am new script learner, so my basic doubt is , how to store value of any command in a variable example $ ls | wc -l i want to stote the output of this in a variable c. so that i can use c in if else loop. and when do we use " ` " symbol in script.. can anyone also tell for... (5 Replies)
Discussion started by: hi2_t
5 Replies

5. Shell Programming and Scripting

Basic Shell Script Help

Lets say I wanted to create a script that would show what people are doing on my machine using the w command and refresh in about 6 seconds. What would be the easiest way to do this? I pretty much want the script to loop until I stop it. I'm using the BASH shell by the way. Help is appreciated.... (1 Reply)
Discussion started by: c4391
1 Replies

6. Shell Programming and Scripting

Basic shell script help

Im trying to make a script that simply adds a word to the last available line in a txt file without overwriting any previous lines. Ive googled this and there are great examples but no one explain what each function does, and i dont entirely understand how it works. Basically Im looking for... (7 Replies)
Discussion started by: kylecn
7 Replies

7. Shell Programming and Scripting

Help! Basic shell script advice

##### (2 Replies)
Discussion started by: AidoPotato
2 Replies

8. UNIX for Dummies Questions & Answers

Shell BASIC interpreter(s)...

I am looking for a simple BASIC Interpreter written in a shell scripting language. For me something like this would be a great learning tool... After much goggle eyed Googling I came upon this:- https://gist.github.com/cander/2785819 It is small and I haven't tried it yet as I am at work... (6 Replies)
Discussion started by: wisecracker
6 Replies

9. UNIX for Dummies Questions & Answers

Shell basic graphics demo.

I have been thinking about another shell scripting project using the Arduino Diecimila board. I was going to make a kids level slow 8 channel Logic Analyser. I thought about using the termiinal esc code graphics characters. This is the test code using said terminal escape codes. I have only... (2 Replies)
Discussion started by: wisecracker
2 Replies

10. UNIX for Dummies Questions & Answers

Basic Shell Scripting

Hi All, I am a newbie to shell scripting. I am trying to something like this. #!bin/bash cd /u01/app/oracle/ # then start the process ./opmnctl startall Can someone help me with this requirement. Help is very much appreciated. Thanks Venkat Please use code tags next time for... (10 Replies)
Discussion started by: venkat8439
10 Replies
GSHADOW(5)						   File Formats and Conversions 						GSHADOW(5)

NAME
gshadow - shadowed group file DESCRIPTION
/etc/gshadow contains the shadowed information for group accounts. This file must not be readable by regular users if password security is to be maintained. Each line of this file contains the following colon-separated fields: group name It must be a valid group name, which exist on the system. encrypted password Refer to crypt(3) for details on how this string is interpreted. If the password field contains some string that is not a valid result of crypt(3), for instance ! or *, users will not be able to use a unix password to access the group (but group members do not need the password). The password is used when an user who is not a member of the group wants to gain the permissions of this group (see newgrp(1)). This field may be empty, in which case only the group members can gain the group permissions. A password field which starts with a exclamation mark means that the password is locked. The remaining characters on the line represent the password field before the password was locked. This password supersedes any password specified in /etc/group. administrators It must be a comma-separated list of user names. Administrators can change the password or the members of the group. Administrators also have the same permissions as the members (see below). members It must be a comma-separated list of user names. Members can access the group without being prompted for a password. You should use the same list of users as in /etc/group. FILES
/etc/group Group account information. /etc/gshadow Secure group account information. SEE ALSO
gpasswd(5), group(5), grpck(8), grpconv(8), newgrp(1). shadow-utils 4.1.5.1 05/25/2012 GSHADOW(5)
All times are GMT -4. The time now is 11:32 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy