The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Advanced & Expert Users
.
google unix.com



UNIX for Advanced & Expert Users Expert-to-Expert. Learn advanced UNIX, UNIX commands, Linux, Operating Systems, System Administration, Programming, Shell, Shell Scripts, Solaris, Linux, HP-UX, AIX, OS X, BSD.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Search, replace string in file1 with string from (lookup table) file2? gstuart Shell Programming and Scripting 9 06-08-2009 07:11 AM
Sorting in C++.. ronix007 High Level Programming 6 03-06-2008 05:16 PM
appending string to text file based on search string malaymaru Shell Programming and Scripting 1 06-09-2006 09:53 AM
awk sorting Jaken Shell Programming and Scripting 4 05-21-2006 10:54 AM
Sorting mp3 penguin-friend Shell Programming and Scripting 3 05-13-2005 04:21 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 01-12-2006
Khoomfire Khoomfire is offline
Registered User
  
 

Join Date: Aug 2005
Posts: 68
Sorting a string

Hello all, I have some 20-digit strings - say 1234567890abcdefghij
I want to remove the 3rd and then the 11-18th strings, but leave a space between the two resulting strings
eg "3 abcdefgh"

I only know how to use "cut", does anyone know any way I can do this? All these strings are in the same file.


Thanks
Khoom

Last edited by Khoomfire; 01-12-2006 at 10:35 AM..
  #2 (permalink)  
Old 01-12-2006
matrixmadhan matrixmadhan is offline Forum Advisor  
Technorati Master
  
 

Join Date: Mar 2005
Location: leaf node in B+ tree
Posts: 2,958
this is for sure hard-coded

anyway it's just a try


Code:
echo 1234567890abcdefghij | sed -e 's/\(..\)\(.\)\(.......\)\(.*\)/\2 \4/'

  #3 (permalink)  
Old 01-12-2006
vino's Avatar
vino vino is offline Forum Staff  
Supporter (in vino veritas)
  
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,798

Code:
[~/temp]$ cat khoom.sh 
#! /bin/sh
VAL=1234567890abcdefghij
echo ${VAL:2:1} ${VAL:10}
[~/temp]$ ./khoom.sh 
3 abcdefghij
[~/temp]$

  #4 (permalink)  
Old 01-12-2006
Khoomfire Khoomfire is offline
Registered User
  
 

Join Date: Aug 2005
Posts: 68
Hi guys,
sorry, but I amended the request at some point, but both alternatives didn't work.

Cheers
Khoom
  #5 (permalink)  
Old 01-12-2006
matrixmadhan matrixmadhan is offline Forum Advisor  
Technorati Master
  
 

Join Date: Mar 2005
Location: leaf node in B+ tree
Posts: 2,958
Quote:
Originally Posted by Khoomfire
Hi guys,
sorry, but I amended the request at some point, but both alternatives didn't work.

Cheers
Khoom
could you please quote your sample input and the output that you are receiving which deviates the required output, so that it would be easier to look into ?
  #6 (permalink)  
Old 01-12-2006
Khoomfire Khoomfire is offline
Registered User
  
 

Join Date: Aug 2005
Posts: 68
Quote:
Originally Posted by matrixmadhan
could you please quote your sample input and the output that you are receiving which deviates the required output, so that it would be easier to look into ?
Hello Matrix,
your option is actually pretty much on course, but I modified my desired output after you helped. What you gave me will give me 3 abcdefghij, but I want 3 abcdefgh

Cheers
Ben
  #7 (permalink)  
Old 01-12-2006
matrixmadhan matrixmadhan is offline Forum Advisor  
Technorati Master
  
 

Join Date: Mar 2005
Location: leaf node in B+ tree
Posts: 2,958
Quote:
Originally Posted by Khoomfire
Hello all, I have some 20-digit strings - say 1234567890abcdefghij
I want to remove the 3rd and then the 11-18th strings, but leave a space between the two resulting strings
eg "3 abcdefghij"

I only know how to use "cut", does anyone know any way I can do this? All these strings are in the same file.


Thanks
Khoom
desired output as requested above : 3 abcdefghij

Quote:
your option is actually pretty much on course, but I modified my desired output after you helped. What you gave me will give me 3 abcdefghij, but I want 3 abcdefgh
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 04:25 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