Sponsored Content
Top Forums Shell Programming and Scripting Removing Letters from Integer String Post 37118 by criglerj on Thursday 12th of June 2003 05:47:28 PM
Old 06-12-2003
Assuming sh, ksh, zsh (, bash?):
Code:
y=1024
z=1024Mb
sizey=`expr "$y" : '\([0-9][0-9]*\)'`
sizez=`expr "$z" : '\([0-9][0-9]*\)'`

$sizey and $sizez will now both be 1024.

Note that oombera's third solution depends on ksh.
 

10 More Discussions You Might Find Interesting

1. Programming

Integer to String

Which function should I use to convert an Integer to a String or Char format ? Thanx (2 Replies)
Discussion started by: psilva
2 Replies

2. Shell Programming and Scripting

Checking if string contains integer

G'day guys, first post so be gentle. I need help with some code to work out if a variable (string) contains any integers. The valid variable (string) must contain only letters. Also need to be able to work out if a variable contains only integers. Any help greatly appreciated. (7 Replies)
Discussion started by: haz
7 Replies

3. Shell Programming and Scripting

Comparing string and integer in IF

hi, I need to create an IF condition. I read a line from a file and get the 5 word using space as a delimited. This word can have only two values either '*' or '1-5' I need to write an IF condition for two cases. I can either compare it to * or 1-5(or even 1 by cutting and getting only the... (3 Replies)
Discussion started by: kaushys
3 Replies

4. UNIX for Dummies Questions & Answers

integer to string

Hi all, is there an easy way to convert integer to string in bash? I have numbers like 1, 2, ..., 112, ... and I would like to get 001 002 003 004 ... Thank you, Sarah (4 Replies)
Discussion started by: f_o_555
4 Replies

5. Shell Programming and Scripting

how to compare string integer with an integer?

hi, how to I do this? i="4.000" if ; then echo "smaller" fi how do I convert the "4.000" to 4? Thanks! (4 Replies)
Discussion started by: h0ujun
4 Replies

6. Homework & Coursework Questions

passing letters from an array into a string for string comparison

attempting the hangman program. This was an optional assignment from the professor. I have completed the logical coding, debugging now. ##I have an array $wordString that initializes to a string of dashes ##reflecting the number of letters in $theWord ##every time the user enters a (valid)... (5 Replies)
Discussion started by: lotsofideas
5 Replies

7. Shell Programming and Scripting

Checking subset and removing extra letters

In each line of file, I wish to check if word1 is a non-connected subset of any of the other words in the line. If yes, keep only the words that ward1 is a subset of. Else, remove the whole line. Also, I want to remove the letters that word1 doesn't match with, except for "_+" Example file:... (2 Replies)
Discussion started by: Viernes
2 Replies

8. Shell Programming and Scripting

awk : match only the pattern string , not letters or numbers after that.

Hi Experts, I am finding difficulty to get exact match: file OPERATING_SYSTEM=HP-UX LOOPBACK_ADDRESS=127.0.0.1 INTERFACE_NAME="lan3" IP_ADDRESS="10.53.52.241" SUBNET_MASK="255.255.255.192" BROADCAST_ADDRESS="" INTERFACE_STATE="" DHCP_ENABLE=0 INTERFACE_NAME="lan3:1"... (6 Replies)
Discussion started by: rveri
6 Replies

9. Shell Programming and Scripting

String to integer

I am on HP-UX using ksh in the script. MaxSal=`sqlplus -silent /nolog <<EOF connect / as sysdba whenever sqlerror exit sql.sqlcode set pagesize 0 feedback off verify off heading off echo off select max(sal) from emp1; select max(sal) from emp2; select max(sal) from emp3; exit; EOF`... (3 Replies)
Discussion started by: bang_dba
3 Replies

10. UNIX for Beginners Questions & Answers

Removing letters after a certain character within a range of columns

Hi there, I am trying to remove al letters after : character on specific columns from 10th column till 827. I used sed and cut to do so but I am sure there is better one liner someone can think of from unix community members. Huge file but it has this structure (Total number of Columns =... (10 Replies)
Discussion started by: daashti
10 Replies
XRUBIK(6)							   Games Manual 							 XRUBIK(6)

NAME
xrubik - Magic cube X widgets SYNOPSIS
/usr/games/xrubik [-geometry [{width}][x{height}][{+-}{xoff}[{+-}{yoff}]]] [-display [{host}]:[{vs}]] [-[no]mono] [-[no]{reverse|rv}] [-{foreground|fg} {color}] [-{background|bg} {color}] [-face{0|1|2|3|4|5} {color}] [-{border|bd} {color}] [-delay msecs] [-[no]sound] [-moveSound {filename}] [-{font|fn} {fontname}] [-view {int}] [-size{x|y|z} {int}] [-[no]orient] [-[no]practice] [-userName {string}] [-scoreFile {filename}] [-scores] [-version] DESCRIPTION
The original puzzle has 9 squares per face (size = 3). The puzzle was designed by Erno Rubik and called the Rubik's Cube. This has 8!*12!*3^8*2^12/12 or 4.3 * 10^19 different combinations. The Pocket Cube has 4 squares per face (size = 2) also designed by Erno Rubik. This has 7!*3^6 or 3,674,160 different combinations. Rubik's Revenge has 16 squares per face (size = 4) also designed by Erno Rubik. This has 7!*3^6*24!*24!/(4!)^6 or 7.4 * 10^46 different combinations. 5x5x5 Cube. This has 8!*12!*3^7*2^10*(24!)^3/(4!)^12 or 2.83 * 10^74 different combinations. There is also the Magic Domino 3x3x2 cube which has (8!)^2/4 or 406,425,600 combinations. A physical 6x6x6 cube is possible but to my knowledge no one has been too successful in building one. 7x7x7 is also possible, but here one must make the center most cubes smaller than the outside cubes, so the corners do not fall off when turned. FEATURES
Press "mouse-left" button to move a piece. Release "mouse-left" button on a piece on the same face and in the same row. The pieces will then turn towards where the mouse button was released. Click "mouse-center", or press "P" or "p" keys to toggle the practice mode (in practice mode the record should say "practice"). This is good for learning moves and experimenting. Click "mouse-right", or press "Z" or "z" keys, to randomize the puzzle (this must be done first to set a new record). Press "G" or "g" keys to get a saved puzzle. Press "W" or "w" keys to save (write) a puzzle. Press "U" or "u" keys to undo a move. Press "R" or "r" keys to redo a move. Press "C" or "c" keys to clear the puzzle. Press "S" or "s" keys to start auto-solver. Only works on 1x1x1, 2x2x2, and 3x3x3 cubes. Press "O" or "o" keys to toggle the orient mode. One has to orient the faces in orient mode, besides getting all the faces to be the same color. To do this one has to get the lines to be oriented in the same direction, this only matters with center piece, if at all (i.e. those pieces not on a corner or edge). This does add complexity so there are 2 sets of records. Press "I" or "i" keys to increase the number of pieces. Press "D" or "d" keys to decrease the number of pieces. Press "x" key to increase the number of pieces along the x axis. Press "X" key to decrease the number of pieces along the x axis. Press "y" key to increase the number of pieces along the y axis. Press "Y" key to decrease the number of pieces along the y axis. Press "f" key to increase the number of pieces along the z axis. Press "F" key to decrease the number of pieces along the z axis. Press "V" or "v" keys to change the view of the cube. Press ">" or "." keys to speed up the movement of pieces. Press "<" or "," keys to slow down the movement of pieces. Press "@" key to toggle the sound. Press "Esc" key to hide program. Press "Q", "q", or "CTRL-C" keys to kill program. Use the key pad or arrow keys to move without the mouse. Key pad is defined for the Rubik2d as: / Counterclockwise 8 Up ^ 4<5>6 Left, Clockwise, Right v 2 Down Key pad for other than Rubik2d, use must use your intuition (is this a cop out or what?). The key pad is defined differently depending on which side of the cube your mouse is pointing at. One thing that stays the same is "5" is Clockwise and "/" is Counterclockwise. Use the control key and the left mouse button, keypad, or arrow keys to move the whole cube. This is not recorded as a turn. The title is in the following format (non-motif non-opengl version): xrubik{2|3}d<dimension>: {1|2|3|4|5|6<cubes per edge on x-axis>x{1|2|3|4|5|6<cubes per edge on y-axis>x{1|2|3|4|5|6<cubes per edge on z-axis>} @ (<Number of moves>/{<Record number of moves> <user name>|"NEVER noaccess"|"practice"}) - <Comment> If there is no record of the current puzzle, it displays "NEVER noaccess". OPTIONS
-geometry {+|-}X{+|-}Y This option sets the initial position of the rubik window (resource name "geometry"). -display host:dpy This option specifies the X server to contact. -[no]mono This option allows you to display the rubik window on a color screen as if it were monochrome (resource name "mono"). -[no]{reverse|rv} This option allows you to see the rubik window in reverse video (resource name "reverseVideo"). -{foreground|fg} color This option specifies the foreground of the rubik window (resource name "foreground"). -{background|bg} color This option specifies the background of the rubik window (resource name "background"). -face{0|1|2|3|4|5} <color> This option allows you to change the color of a face (resource name "faceColorN"). In mono-mode, color is represented as the first letter of the color name. On the 2-D version, the faces are ordered top to bottom and left to right on the "t" configuration. The sideways "t" or "+-" configuration is physically consistent with the former, so it is ordered "0, 1, 2, 3, 5, 4". If you has two colors that begin with the same letter you should have one in uppercase and one in lowercase to distinguish them in mono-mode. You can change the colors of the faces to make a stupid cube (i.e. all White or in mono-mode all "W"). Unfortunately, it will not nor- mally say its solved when its randomized. This would be cheating. -{border|bd} color This option specifies the border color of the pieces in the rubik window (resource name "borderColor"). -delay msecs This option specifies the number of milliseconds it takes to move pieces (1-50) (resource name "delay"). -[no]sound This option specifies if sliding pieces should make a sound or not (resource name "sound"). -moveSound filename This option specifies the file for the move sound the twisting of the puzzle (resource name "moveSound"). -{font|fn} ontname This option specifies the font that will be used (resource name "font"). -view <int> This option allows you to change the view of the cube for OpenGL with choice of 4 views (resource name "int"). -sizex <int> This option allows you to change the number of pieces on a edge along x-axis (resource name "sizex"). -sizey <int> This option allows you to change the number of pieces on a edge along y-axis (resource name "sizey"). -sizez <int> This option allows you to change the number of pieces on a edge along z-axis (resource name "sizez"). -[no]orient This option allows you to access the orient mode (resource name "orient"). -[no]practice This option allows you to access the practice mode (resource name "practice"). -userName string This option specifies the user name for any records made or else it will get your login name (resource name "userName"). -scoreFile filename Specify an alternative score file (resource name "scoreFile"). -scores This option lists all the recorded scores and then exits. -version This option tells you what version of xrubik you have. RECORDS
You must randomize the puzzle before a record is set, otherwise an assumption of cheating is made if it is solved after a get or an auto-solve. SAVE FORMAT
Here is the format for the xrubik configuration, starting position, and the movement of its pieces. The format is not standard. The rea- son is that this is simple to produce and the standard notation is no good for variable number of pieces. Rubik2d with default colors, not randomized (front is face 2) : 0 R Red 1 2 3 Y W G Yellow, White, Green 4 O Orange 5 B Blue sizex: 1-6 <the number of cubes per row along x-axis> sizey: 1-6 <the number of cubes per row along y-axis> sizez: 1-6 <the number of cubes per row along z-axis> orient: 0-1 <0 false, 1 true; if 1 then lines on pieces to be oriented> practice: 0-1 <0 false, 1 true> moves: 0-MAXINT <total number of moves> startingPosition: <2 dimensional array of face and piece position, each face has size1 * size2 pieces, if orient mode then orienta- tion number follows face number: 0 up, 1 right, 2 down, and 3 left> This is then followed by the moves, starting from 1. move #: <face> <position> <direction> <control> Each turn is with respect to a face and position. Position is 0 to size * size - 1. Position 0 is in the upper left. Direction is represented as 0 up, 1 right, 2 down, 3 left, 5 clockwise, and 7 counterclockwise. Control is represented as 0 or 1, 1 if the whole cube is moved at once (here position does not matter), 0 if not. The xrubik record keeper does not count a control move as a move, but here we do. If you have a Rubik's Cube you can not solve (2x2x2 or 3x3x3) enter it in rubik.log file. Have size = 2 or 3, orient = 0, practice = 0, randomized = 1, and moves = 0 and the number representation for the color of the piece (usually 0=R, 1=Y, 2=W, 3=G, 4=O, 5=B). Bring up xrubik, hit 'g' so it will get your configuration and then 's' to solve your cube and then 'w' to write out the steps. Then examine your rubik.log file. REFERENCES
Inside Rubik's Cube and Beyond by Christoph Bandelow, Birkhauser, 1982. pp 44, 45, 88, 89 Magic Cubes 1996 Catalog of Dr. Christoph Bandelow. The Simple Solution To Rubik's Cube, James G. Nourse, June 1981 Rubik's Cube Newsletter by Ideal Aug 1982 Vol.1 No. 2 Rubik's Cube The Solution, Ideal Toy Corporation, 1981 Rubik's Revenge Puzzle The Solution, Ideal Toy Corporation, 1982 SEE ALSO
X(1), xcubes(6), xtriangles(6), xhexagons(6), xmlink(6), xbarrel(6), xpanex(6), xmball(6), xpyraminx(6), xoct(6), xskewb(6), xdino(6), xabacus(6) COPYRIGHTS
(R) Copyright 1994-2010, David A. Bagley Michael B. Martin, <martinm@sps1.phys.vt.edu> wrote an independent program cubist10.c-- for IBM PC. I added the auto-solve code into xru- bik, with his permission. BUG REPORTS AND PROGRAM UPDATES
Send bugs (or their reports, or fixes) to the author: David A. Bagley, <bagleyd@tux.org> The latest version is currently at: http://www.tux.org/~bagleyd/puzzles.html ftp://ibiblio.org/pub/Linux/games/strategy V7.5.6 13 Jan 2010 XRUBIK(6)
All times are GMT -4. The time now is 07:09 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy