Computing.Net > Forums > Unix > I need help with my skript.

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

I need help with my skript.

Reply to Message Icon

Name: Anja2004
Date: January 11, 2004 at 16:10:31 Pacific
OS: Unix
CPU/Ram: donno
Comment:

Hello! i hope somebody can help me.
I would like to have help with an shell script(sh) assignment.
I have a file and it contains something like the following text:

02gozal:godam:godhar:TGFGK:halllo
23david:david:edsson:FDSFF:halllo
32farad:fazdg:forum:HGHJ:halllo
and so on...
Now I want a script code to take this file and print out the following text.. (skriptexample.sh textx.txt)

23david david, edsson
32farad fazdg, forum
02gozal godam, godhar
and on...

The last word should be in a alphabetical order.

I have started writing down the code:

sort -k3 -t: $1 | cut -f1,2,3 -d':' |
after this it get's a little bit confusing
while
IFS=:
read a
read b
read c
do
echo "$a $b $c"
done

So please help me, a really want to know but I don't know what to do :(
I hope you can email me and help me /Anja



Sponsored Link
Ads by Google

Response Number 1
Name: nails
Date: January 12, 2004 at 15:29:22 Pacific
Reply:

Hi:

Why not use awk to parse the file and sort on the 3rd field:

awk ' BEGIN { FS=":" }
{
printf("%s %s, %s\n", $1, $2, $3)
} ' file.txt|sort -k 3,3

Regards,

Nails


0

Response Number 2
Name: frank.gerigk
Date: January 13, 2004 at 02:26:19 Pacific
Reply:

Hi,

a sh solution could be

IFS=:
sort -k3 -t: bla.txt | while read a b c rest
do
echo $a $b $c
done
IFS='
'


No RISK no fun

Frank


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More


E-mail script Recursive mget?



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: I need help with my skript.

For anyone who needs help with the i810 graphics www.computing.net/answers/unix/for-anyone-who-needs-help-with-the-i810-graphics/681.html

need help with finger command. www.computing.net/answers/unix/need-help-with-finger-command/4284.html

help with a sed function www.computing.net/answers/unix/help-with-a-sed-function/4297.html