The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Accessing variables of one shell script in another shell script rsendhilmani Shell Programming and Scripting 2 03-17-2009 01:17 AM
invoking a shell script inside cgi shell script smriti_shridhar Shell Programming and Scripting 2 07-09-2008 02:50 AM
Accessing variables of one shell script in another shell script looza Shell Programming and Scripting 2 06-30-2008 08:13 PM
How to pass a parameter from one Shell-script to another Shell-script subodhbansal Shell Programming and Scripting 2 09-22-2007 06:19 AM
Have a shell script call another shell script and exit heprox Shell Programming and Scripting 2 11-20-2006 08:17 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 11-23-2008
halola85 halola85 is offline
Registered User
  
 

Join Date: Nov 2008
Posts: 13
shell script by sed

Hey everybody

I need some help on how to order the data in file such as a file have first name last name and city and i would like to order them to in the same order by using sed

thanks alot for your time
  #2 (permalink)  
Old 11-24-2008
elbrand elbrand is offline
Registered User
  
 

Join Date: Apr 2008
Location: Wolfenbuettel/Germany
Posts: 12
shell script by sed

why not use "sort" to sort?
  #3 (permalink)  
Old 11-24-2008
Tytalus's Avatar
Tytalus Tytalus is offline Forum Advisor  
echo {1..9}^2\;|bc
  
 

Join Date: Jun 2003
Location: Scotland
Posts: 431
Post some sample input and expected output.

Also, what have you tried so far ?
  #4 (permalink)  
Old 11-24-2008
halola85 halola85 is offline
Registered User
  
 

Join Date: Nov 2008
Posts: 13
Hey ..
here is a sample
and i would like to sort it to order it to be
username then the,shell, after that home directory
rootbash:x:0:1:0000-Admin(0000):/:/usr/local/bin/bash
rootnt:x:0:1:0000-Admin(0000):/:/usr/local/bin/bash
daemon:x:1:1:0000-Admin(0000):/:/usr/local/bin/bash
nobody:x:60001:60001:uid no body:/:/usr/local/bin/bash
noaccess:x:60002:60002:uid no access:/:/usr/local/bin/bash

thank you ...
  #5 (permalink)  
Old 11-24-2008
elbrand elbrand is offline
Registered User
  
 

Join Date: Apr 2008
Location: Wolfenbuettel/Germany
Posts: 12
shell script by sed

I would prefer awk for this:


Code:
    awk -F ':' '{printf("%s:%s:%s\n", $1, $7, $6)}' datafile.txt

but sed could work too:


Code:
    sed 's/^\([^:]*\):[^:]*:[^:]*:[^:]*:[^:]*:\([^:]*\):\([^:]*\)/\1:\3:\2/g' datafile.txt

  #6 (permalink)  
Old 11-24-2008
chatwizrd chatwizrd is offline
Banned
  
 

Join Date: Nov 2008
Posts: 67
Why wouldnt you just use cut command ?????????????
  #7 (permalink)  
Old 11-25-2008
halola85 halola85 is offline
Registered User
  
 

Join Date: Nov 2008
Posts: 13
thank you everybody very much
for your time
Closed Thread

Bookmarks

Tags
shell script, shell scripting, unix scripting, unix scripting basics

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 07:02 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0