Sponsored Content
Full Discussion: Query on decision making...
Top Forums Shell Programming and Scripting Query on decision making... Post 302475616 by frans on Monday 29th of November 2010 09:39:44 AM
Old 11-29-2010
Quote:
Originally Posted by biglau
That's right, but why [[ ]] does not support `` ?
As your function has all its outputs redirected to /dev/null, it outputs nothing.
so the test [[ `is_number 0100` ]] is interpreted as [[ ]] with nothing inside.

By the way, the function could be written: is_number() { echo $1 | egrep -q '^[1-9][0-9]*$'; }
  • The -q (quiet) option removes output
  • The return code of the function is the return code of the last command in it

---------- Post updated at 15:39 ---------- Previous update was at 15:35 ----------

Quote:
Originally Posted by biglau
bro, what if I need to put multiple conditions in an if statement without using the brackets?
like:
if is_number $3 || $# -ne 3
Tthe first part doesn't need test (where the brackets stand for) bur the second, yes. Youi should write
Code:
if is_number $3 || [ $# -ne 3 ]
# or using arithmetic evaluation
if is_number $3 || (( $# != 3 ))

 

6 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

decision, case, it then else?

I'm writing this script in Korn Shell, on AIX. The script will print a log file, and it needs to decide what region it's in before printing. ( the output of db2 "get instance" is either "The current database manager instance is: db2q" or "The current database manager instance is: db2u") ... (6 Replies)
Discussion started by: jpprial
6 Replies

2. UNIX for Dummies Questions & Answers

Platform decision

Hi folks First, let me apologize in advance for the long message. I know this will sound like a typical "newbie" message but I am really working to understand the technology in order to make informed decisions. I am currently in the process of evaluating Unix hardware and OS platforms for an... (5 Replies)
Discussion started by: Scooter
5 Replies

3. Shell Programming and Scripting

Numerical Decision

I'm tryning to do something like this, I have this file: spaces12tabgoodbye spaces3tabhello I want to copy to another file the lines that have the number above 10... I thought using sort -rn but I don't know how to discard the lines that have the number below 10. Any idea? Thanks (3 Replies)
Discussion started by: pmpx
3 Replies

4. Shell Programming and Scripting

shell script with decision making

Hi all I need help for the issue below. I need to create script: FORM_cmd=query || import FORM_command=add FORM_msisdn=389881234567 FORM_provcode=SK FORM_attr=12 FORM_cmd can be "query" or "import" when FORM_cmd="query" then execute -> spdci -cmd $FORM_cmd FORM_cmd when... (3 Replies)
Discussion started by: vasil
3 Replies

5. Shell Programming and Scripting

Regarding a query on making changes to a running script

Hello All, Greetings !! I have a query here to all is as follows: Question: Let's say we are running a script in a UNIX box and we have opened an another session and then made changes in script of some statements NOT to be print some values(just an example) so when I am monitoring the... (5 Replies)
Discussion started by: RavinderSingh13
5 Replies

6. UNIX for Beginners Questions & Answers

Handling decision making logic

------- Output Screen -------- Choose the option ----------------- 1.Input 2.Output 3.CFT Uniq x.Exit ----------------- 2 Enter the Output flow IDF PBL5572U Enter the Output existing flow IDF PBL5198H sf_PBL5572U.cmd file exist in invalid path or doesn't exist (0 Replies)
Discussion started by: Vijaykannan T
0 Replies
ppmtosixel(1)						      General Commands Manual						     ppmtosixel(1)

NAME
ppmtosixel - convert a portable pixmap into DEC sixel format SYNOPSIS
ppmtosixel [-raw] [-margin] [ppmfile] DESCRIPTION
Reads a portable pixmap as input. Produces sixel commands (SIX) as output. The output is formatted for color printing, e.g. for a DEC LJ250 color inkjet printer. If RGB values from the PPM file do not have maxval=100, the RGB values are rescaled. A printer control header and a color assignment table begin the SIX file. Image data is written in a compressed format by default. A printer control footer ends the image file. OPTIONS
-raw If specified, each pixel will be explicitly described in the image file. If -raw is not specified, output will default to com- pressed format in which identical adjacent pixels are replaced by "repeat pixel" commands. A raw file is often an order of magni- tude larger than a compressed file and prints much slower. -margin If -margin is not specified, the image will be start at the left margin (of the window, paper, or whatever). If -margin is speci- fied, a 1.5 inch left margin will offset the image. PRINTING
Generally, sixel files must reach the printer unfiltered. Use the lpr -x option or cat filename > /dev/tty0?. BUGS
Upon rescaling, truncation of the least significant bits of RGB values may result in poor color conversion. If the original PPM maxval was greater than 100, rescaling also reduces the image depth. While the actual RGB values from the ppm file are more or less retained, the color palette of the LJ250 may not match the colors on your screen. This seems to be a printer limitation. SEE ALSO
ppm(5) AUTHOR
Copyright (C) 1991 by Rick Vinci. 26 April 1991 ppmtosixel(1)
All times are GMT -4. The time now is 04:20 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy