UNIX Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsOperating SystemsUNIX Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now!
  #1  
Old September 30th, 2004, 08:58 PM
jun_moti jun_moti is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Posts: 7 jun_moti User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
How to cut and concat in KSH... pls help....

I was tasked to get the first 8 and last 18 characters of each line of a file... then concat the two strings in a file.... pls help... the source file is .dat...... tnx....

-jun

Reply With Quote
  #2  
Old September 30th, 2004, 11:05 PM
guggach guggach is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jul 2004
Location: Middle Europa
Posts: 1,083 guggach User rank is Corporal (100 - 500 Reputation Level)guggach User rank is Corporal (100 - 500 Reputation Level)guggach User rank is Corporal (100 - 500 Reputation Level)guggach User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 4 Days 19 h 44 m 45 sec
Reputation Power: 9
sed 's/^\(.\{8\}\).*\(.\{18\}\)$/\1\2/' input > outup

Reply With Quote
  #3  
Old October 1st, 2004, 02:28 AM
jun_moti jun_moti is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Posts: 7 jun_moti User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Quote:
Originally Posted by guggach
sed 's/^\(.\{8\}\).*\(.\{18\}\)$/\1\2/' input > outup


i have this example

abcdefghijk....................123456789011121315
lmnopqrstu.....................513121110987654321

the output on the file should be

abcdefgh123456789011121315
lmnopqrs513121110987654321

I tried to run the command but its copying the whole string.... m not a unix guy... pls bare with me.... tnx

Reply With Quote
  #4  
Old October 1st, 2004, 04:11 AM
guggach guggach is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jul 2004
Location: Middle Europa
Posts: 1,083 guggach User rank is Corporal (100 - 500 Reputation Level)guggach User rank is Corporal (100 - 500 Reputation Level)guggach User rank is Corporal (100 - 500 Reputation Level)guggach User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 4 Days 19 h 44 m 45 sec
Reputation Power: 9
exactly what that sed does.

Reply With Quote
  #5  
Old October 3rd, 2004, 10:24 PM
jun_moti jun_moti is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Posts: 7 jun_moti User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Quote:
Originally Posted by guggach
exactly what that sed does.


tnx guggach.... I was having a server problem that is why the command was not performing properly.... till next time... -jun

Reply With Quote
  #6  
Old October 6th, 2004, 03:53 AM
Muthukumar_K Muthukumar_K is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Posts: 13 Muthukumar_K User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via Yahoo to Muthukumar_K
We can do this with awk command too as,

awk '{ print substr($1,1,8)substr($1,length($1)-18,length($1)) }' file

Example:

# echo "abcdefghijk....................123456789011121315" | awk '{ print substr($1,1,8)substr($1,length($1)-18,length($1)) }'
abcdefgh.123456789011121315


Regards
Muthukumar

Reply With Quote
Reply

Viewing: Dev Shed ForumsOperating SystemsUNIX Help > How to cut and concat in KSH... pls help....


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway