|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
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
|
|||
|
|||
|
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 |
|
#2
|
|||
|
|||
|
sed 's/^\(.\{8\}\).*\(.\{18\}\)$/\1\2/' input > outup
|
|
#3
|
|||
|
|||
|
Quote:
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 |
|
#4
|
|||
|
|||
|
exactly what that sed does.
|
|
#5
|
|||
|
|||
|
Quote:
tnx guggach.... I was having a server problem that is why the command was not performing properly.... till next time... -jun |
|
#6
|
|||
|
|||
|
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 |
![]() |
| Viewing: Dev Shed Forums > Operating Systems > UNIX Help > How to cut and concat in KSH... pls help.... |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|