Sponsored Content
Full Discussion: Crazy Dots
Homework and Emergencies Homework & Coursework Questions Crazy Dots Post 302458040 by methyl on Wednesday 29th of September 2010 11:18:50 AM
Old 09-29-2010
To handle both "h" (horizontal dots) and "v" (vertical dots) in the same script you will need to change the structure of the script slightly bearing in mind the previous post about the different ways of comparing strings and integers.

A script becomes easier to read if we save the input parameters to named variables early in the script.

For example:

Code:
if [ $# -ne 2 ]
then
    echo "Usage: `basename $0` [h|v] dot_count"
    exit
fi
#
dot=0
orientation="$1"
dot_count=$2

while [ ${dot} -lt ${dot_count} ]
do
   # Horizontal
   if [ "${orientation}" = "h" ]
   then
       printf "."       # No linefeed
   fi
   # Vertical
   if [ "${orientation}" = "v" ]
   then
       printf ".\n"     # With linefeed
   fi
   #
   dot=`expr $dot + 1`
done
#
if [ "${orientation}" = "h" ]
then
   printf "\n"  # End the horizontal dots with a linefeed
fi

 

10 More Discussions You Might Find Interesting

1. Programming

maximum number of dots in a domain name

maximum number of dots in a domain name - not a sub-domain name. for example: mydomain.com ------ one dot mydomain.com.au ------ two dots do you know maximum number of dots in a domain name and could you provide a sample? thx. (1 Reply)
Discussion started by: hello20009876
1 Replies

2. UNIX for Dummies Questions & Answers

dots and slashes

when I execute a command in like "run.sh," I can run it two ways: ./run.sh or . run.sh What is the difference? (1 Reply)
Discussion started by: DarkLord
1 Replies

3. Programming

Printing Dots in specific Locations in the Console ?

Point.h #pragma once #include <iostream> using namespace std; class Point { private: int x; int y; public: Point(void); Point( int x, int y ); Point( const Point &xPoint ); ~Point(void); (0 Replies)
Discussion started by: Max_Payne
0 Replies

4. Shell Programming and Scripting

Stripping out extensions when file has multiple dots in name

I posted this already in another thread, but was told that I should create a seperate thread for the following question: How do I strip the extension when the delimiter might occur multiple times in the filename? For example: I have 2 files as input for my script. test.extension... (8 Replies)
Discussion started by: Nemelis
8 Replies

5. UNIX for Dummies Questions & Answers

using dots to change directories

how would i go down a directory using the ../.. (6 Replies)
Discussion started by: JamieMurry
6 Replies

6. Shell Programming and Scripting

Replace multiple dots (.) with spaces ( )

Hi all, I have files in the filename pattern of, this.is.the.name.of.my.file.mov and I would like to remove dots (.) and replace them with spaces ( ) so the output would be, this is the name of my file.mov The other issue that I have is that the number of dots (.) in the file... (6 Replies)
Discussion started by: Monkey Dean
6 Replies

7. Shell Programming and Scripting

search line with more than two dots if so throw error

Hi, I have a requirement like i have to search a script and find names that conatins more than two dots, if so then throw error. For ex: a1.b1.comname here i have to find comname and check two dots. it will not throw error a1.b1.c1.comname here it contains more than 2dots it will throw... (3 Replies)
Discussion started by: swagat123
3 Replies

8. Shell Programming and Scripting

Remove filenames beginning with multiple dots

hi all, I want to remove filenames beginning with multiple dots.how I can do this. Thanks in advance (5 Replies)
Discussion started by: sriharsharavi
5 Replies

9. Shell Programming and Scripting

Get file extension with multiple dots

I am trying to get the file extension with file names that could contain multiple dots using shell scripting. I want to find a way using the sed command. Example Filenames: one.dat one.dat.002 Results: dat I would like to return dat in both instances using the sed command. How can I... (4 Replies)
Discussion started by: smkremer
4 Replies

10. Shell Programming and Scripting

underscore to dots

Hi, I have been trying to change underscores to dots. For example: 1122_91 1022_233 . 2237_23 9382_2339 2998_234 345_257 . . Desired output: 1122.91 1022.233 . 2237.23 9382.2339 2998.234 345.257 . . Any idea? Thanks (4 Replies)
Discussion started by: iconig
4 Replies
XmConvertUnits(3X)														XmConvertUnits(3X)

NAME
XmConvertUnits - A function that converts a value in one unit type to another unit type SYNOPSIS
#include <Xm/Xm.h> int XmConvertUnits (widget, orientation, from_unit_type, from_value, to_unit_type) Widget widget; int orientation; int from_unit_type; int from_value; int to_unit_type; DESCRIPTION
XmConvertUnits converts the value and returns it as the return value from the function. Specifies the widget for which the data is to be converted Specifies whether the converter uses the horizontal or vertical screen resolution when performing the conversions. orientation can have values of XmHORIZONTAL or XmVERTICAL. Specifies the current unit type of the supplied value Specifies the value to be converted Converts the value to the unit type specified The parameters from_unit_type and to_unit_type can have the following values: XmPIXELS--all values provided to the widget are treated as normal pixel values. This is the default for the resource. Xm100TH_MILLIMETERS--all values provided to the widget are treated as 1/100 millimeter. Xm1000TH_INCHES--all values provided to the widget are treated as 1/1000 inch. Xm100TH_POINTS--all values provided to the widget are treated as 1/100 point. A point is a unit typically used in text processing applications and is defined as 1/72 inch. Xm100TH_FONT_UNITS--all values provided to the widget are treated as 1/100 of a font unit. A font unit has horizontal and vertical compo- nents. These are the values of the XmScreen resources XmNhorizontalFontUnit and XmNverticalFontUnit. RETURN VALUE
Returns the converted value. If a NULL widget, incorrect orientation, or incorrect unit_type is supplied as parameter data, 0 is returned. SEE ALSO
XmSetFontUnits(3X), XmScreen(3X) XmConvertUnits(3X)
All times are GMT -4. The time now is 01:43 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy