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
Regarding Shell Scripting anilkarikkandar UNIX for Dummies Questions & Answers 3 11-20-2006 12:26 AM
HELP PLS!! Shell Scripting!! Mary_xxx Shell Programming and Scripting 9 09-16-2006 06:52 AM
difference between AIX shell scripting and Unix shell scripting. haroonec Shell Programming and Scripting 2 04-12-2006 08:12 AM
something else on shell scripting master_6ez Shell Programming and Scripting 1 11-21-2004 11:42 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 01-28-2008
smr_rashmy smr_rashmy is offline
Registered User
  
 

Join Date: Sep 2007
Posts: 37
need help in shell scripting

Hi frnds,

Please help me with the following,

see the script below,

v1="Good"
v2="Morning"
v1="$v1 "
v2="$v2 "
v1=`"$v1" | cut -c1-10`
v2=`"$v2" | cut -c1-10`
echo $v1$v2

This thing is, i want to pring it like "Good Morning"

i need some specific gap in between.

or is there any other way to do this?

Thanks in advance,
Raja.
  #2 (permalink)  
Old 01-28-2008
Yogesh Sawant's Avatar
Yogesh Sawant Yogesh Sawant is offline Forum Staff  
Part Time Moderator and Full Time Dad
  
 

Join Date: Sep 2006
Location: Rossem, Tazenda
Posts: 1,086
this works for me:
Code:
v1="good"
v2="morning"
echo $v1 $v2
do you want a gap of more than one space?
then:
Code:
v1="good"
v2="morning"
echo $v1 "     " $v2
  #3 (permalink)  
Old 01-28-2008
dennis.jacob dennis.jacob is offline Forum Advisor  
dj -------
  
 

Join Date: Feb 2007
Location: Cochin/Singapore
Posts: 515
Or you can try:
Code:
echo "$v1                            $v2"
  #4 (permalink)  
Old 01-28-2008
smr_rashmy smr_rashmy is offline
Registered User
  
 

Join Date: Sep 2007
Posts: 37
Yes this is working...

the scenario is,

i will get values from some other files to variables.

those variables may contain blank spaces.
and i need to write the empty spaces also.

like v1="aaa "
v2=" "
v3="BBB"

i want to write these variables into a file with the blank spaces. coz some other program will read it based on the positions.

Note: Even if some variables contains more length say 15 and i may required to get only 10.

does it make any sense frnd?

Last edited by smr_rashmy; 01-28-2008 at 04:33 AM..
  #5 (permalink)  
Old 01-28-2008
Yogesh Sawant's Avatar
Yogesh Sawant Yogesh Sawant is offline Forum Staff  
Part Time Moderator and Full Time Dad
  
 

Join Date: Sep 2006
Location: Rossem, Tazenda
Posts: 1,086
Code:
v1="good"
v2="morning"
gap="    "
echo "$v1 $gap $v2" > newfile
does this help?
Sponsored Links
Closed Thread

Bookmarks

Tags
echo, shell scripting

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 01:12 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language translation by Google.
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