To display 1 or 2 space bar output


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting To display 1 or 2 space bar output
# 1  
Old 02-11-2006
To display 1 or 2 space bar output

Dear Experts,

Please help to advice me for the command to show the output below:-
1) If i input 3, 201, 222 then the output should show 1 space bar as below
201 222
2) If i input 4, 201, 1509 then the outpur should show 2 span bar as below
201 1509

3 will be for 1 space bar between 201 and 222
4 will be for 2 space bar between 201 and 1509

Here below is my script but it cannot work. Please help correct

Code:
echo "Please enter the number of digit BTS-ID"
read digit 
echo "Please enter MM#"
read mm
echo "Please enter BTS#"
read bts 

if ["digit" = 3]
  then
    echo "$mm  $bts" > mmbts
    exit 0

  else
    echo "$mm $bts" > mmbts
fi


Last edited by Perderabo; 02-11-2006 at 04:16 PM.. Reason: Add code tags for readability
# 2  
Old 02-11-2006
not tested.....

Code:
#!/bin/ksh

typeset -i digit, mm, bts

echo "Please enter the number of digit BTS-ID"
read digit
echo "Please enter MM#"
read mm
echo "Please enter BTS#"
read bts

if (( digit == 3 ))
then
  echo "$mm $bts" > mmbts
else
  echo "$mm $bts" > mmbts
fi

# 3  
Old 02-11-2006
You don't need to enter the length of a variable. You can find it with #. And you can typeset a variable so it is always at least 4 characters...spaces added as needed.

Code:
#! /usr/bin/ksh

typeset -R4 rbts
echo "Please enter MM#"
read mm
echo "Please enter BTS#"
read bts

echo bts is $bts which has ${#bts} digits
rbts=$bts
echo "$mm $rbts"
exit 0

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Gawk --- produce the output in pattern space instead of END space

hi, I'm trying to calculate IP addresses and their respective calls to our apache Server. The standard format of the input is HOST IP DATE/TIME - - "GET/POST reuest" "User Agent" HOST IP DATE/TIME - - "GET/POST reuest" "User Agent" HOST IP DATE/TIME - - "GET/POST reuest" "User Agent" HOST... (2 Replies)
Discussion started by: busyboy
2 Replies

2. Shell Programming and Scripting

Help with script to display space usage

Hi all, I am looking for help with a script for displaying the space available from a df - h command for / (root). The problem is: If it is below 700 MB I have jobs that are failing... Is there a way I can do a calculation? If it above 700 MB it is good, if it is below 700 MB it will fail.... (5 Replies)
Discussion started by: gartie
5 Replies

3. UNIX for Dummies Questions & Answers

Display Pie Chart/Bar Graph in microsoft outlook email using UNIX commands/Shell scripts

I have a shell script which executes to write html codes into a text file. My next step is to email the text file so that receiving person (people who i send email to) should be able to see pie/chart or bar graph (whatever i design in my code) in their email. Following is the example of a sample... (7 Replies)
Discussion started by: bikerboy
7 Replies

4. Shell Programming and Scripting

how to display column value in a row with space as delimeter

Hi I need to write a small script to kill the process id of particular job in one shot , Example > ps PID TTY TIME COMMAND 16280 pts/70 0:00 sh 16278 pts/70 0:00 rlogind 16197 pts/70 0:00 ps 1234 pts/70 0:00 runflow 2341 pts/70 0:00 runflow 12673 pts/70 ... (6 Replies)
Discussion started by: mani_isha
6 Replies

5. Linux

Space bar issue in Vi editor on Linux - Solaris

Hi I have a process generating a file in Solaris. Now we have migrated the process to Linux. When we open the file in vi on solaris and hit space bar, it stops after reaching the end of line. But in linux it continues to go on the next line. So I want to know whether the difference is between the... (4 Replies)
Discussion started by: sudhamacs
4 Replies

6. Shell Programming and Scripting

Pressing "Enter/Space bar" using Net::TELNET? in Perl

I'm trying to learn how to get my script to execute the enter button when it telnets into a router and the router displays output but you need to press the space bar or enter button to continue displaying my output of the router. How is this done? (0 Replies)
Discussion started by: xmaverick
0 Replies

7. Shell Programming and Scripting

Replace space and vertical bar with verical bar

I am trying to get sed, tr or awk to search a file that contains records with fields delimited by the vertical bar | and replace the occurrences in the records where the vertical bar is preceded by a space " |" with a vertical bar. Sample data record zelli |||59 Stonewall Dr ||W Barnstable |MA... (2 Replies)
Discussion started by: clintrpeterson
2 Replies

8. UNIX for Dummies Questions & Answers

Command display output on console and simultaneously save the command and its output

Hi folks, Please advise which command/command line shall I run; 1) to display the command and its output on console 2) simultaneous to save the command and its output on a file I tried tee command as follows; $ ps aux | grep mysql | tee /path/to/output.txt It displayed the... (7 Replies)
Discussion started by: satimis
7 Replies

9. Shell Programming and Scripting

display free space on a unix server

I need to display the amount space avalible on a unix server in an html webpage, which will automatically update every hour. I am able to do so using a javascript in a windows based server. How would i go about doing this in a unix server. Any help, suggestions, anything would be great. thanks. (3 Replies)
Discussion started by: davwel
3 Replies

10. UNIX for Dummies Questions & Answers

Want display a line with space in file by unix script

HI , I am having a file as -----------------a.out------------------- Hi I am unix developer using hp unix this is a test --------------------------------------- i need to read each line by a unix script of the file and to print in console with the space in the line as ... (9 Replies)
Discussion started by: arunkumar_mca
9 Replies
Login or Register to Ask a Question