The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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
split string using separetor rinku Shell Programming and Scripting 10 06-16-2009 02:01 PM
[KSH] Split string into array piooooter Shell Programming and Scripting 3 09-01-2007 12:22 PM
KSH split string into variables drd_2b Shell Programming and Scripting 5 04-23-2006 07:07 PM
split a string gazingdown Shell Programming and Scripting 3 02-09-2006 05:34 AM
split a file at a specified string jpl35 Shell Programming and Scripting 6 07-04-2002 11:41 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 03-27-2006
senthilk615 senthilk615 is offline
Registered User
  
 

Join Date: Mar 2006
Posts: 16
split string help

could anyone help in running split cmd

split("String1,outputArray,"delimiter);
with sample script?.


for eg i have abc-def-ghi-sdf-

my ultimate aim of asking this is i have a string containing hypens,
i want to get the string before last n(2) Hypens

Last edited by senthilk615; 03-27-2006 at 05:10 PM..
  #2 (permalink)  
Old 03-27-2006
rajeeb_d rajeeb_d is offline
Registered User
  
 

Join Date: Feb 2006
Posts: 37
Examples

Could you give an example of the string and how you want it to look finally.
  #3 (permalink)  
Old 03-27-2006
vgersh99's Avatar
vgersh99 vgersh99 is offline Forum Staff  
Moderator
  
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 5,122
Code:
echo 'abc-def-ghi-sdf-' | nawk -F- -v OFS=- -v num=2 '{NF-=num; $1=$1; print}'
  #4 (permalink)  
Old 03-27-2006
senthilk615 senthilk615 is offline
Registered User
  
 

Join Date: Mar 2006
Posts: 16
i get ksh: nawk: not found error. i am using sunOS v5.8
  #5 (permalink)  
Old 03-27-2006
vgersh99's Avatar
vgersh99 vgersh99 is offline Forum Staff  
Moderator
  
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 5,122
Quote:
Originally Posted by senthilk615
i get ksh: nawk: not found error. i am using sunOS v5.8
tried locating '/usr/bin/nawk' and/or '/usr/xpg4/bin/awk' ?
Closed Thread

Bookmarks

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 02:14 PM.


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