Sponsored Content
Top Forums Shell Programming and Scripting 1 Command - 2 Behaviours and a wrong false message Post 302931068 by Don Cragun on Friday 9th of January 2015 11:20:28 PM
Old 01-10-2015
Try changing:
Code:
check=$(echo "$1" | tr -d [:digit:])

to:
Code:
check=$(echo "$1" | tr -d '[:digit:]')

Double quotes should also work as well as single quotes in this example. (I generally prefer single quotes when quoting constant strings.)

PS
I should have said why the quotes are needed...
The unquoted argument [:digit:] is a pathname bracket expression that changes to a list of files with the single character names :, d, i, g, and t if any such files are present in the directory where you run this command. If you run it in a directory where there are no files matching this pattern, the unchanged pattern is passed to tr as an operand. So, the reason it works sometimes and fails sometimes is the contents of the directory where it is run; not the script used to invoke it.

Last edited by Don Cragun; 01-10-2015 at 12:41 AM.. Reason: Add PS.
This User Gave Thanks to Don Cragun For This Post:
 

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Whats wrong with the mv command

I am sorry guys I have figured out the error myself. (0 Replies)
Discussion started by: dsravan
0 Replies

2. Shell Programming and Scripting

Is anything wrong with this command

Hi All, can anyone tell me what is wrong with this command. tail -f /opt/olr-logs/PaymentGateway.log | grep "DEBUG - Start! AkhtarPaymentGateway - generateChecksum" | awk '{print $13}' | sed 's/,//g'>> abc But I found nothing in the file abc Please do help me.or Provide me some... (8 Replies)
Discussion started by: akhtar.bhat
8 Replies

3. UNIX for Advanced & Expert Users

what is wrong with this find command

i am trying to find the files which are more than 100MB and it was created 10 days ago. find /lola/loaded -size +102400 -mtime -10 -print | xargs ls -ltr -rw-rw-r-- 1 lola_adm gdrmp 82054170 Jun 23 06:17 /lola/loaded/ILMEMBER20090622.txt -rw-rw-r-- 1 lola_adm gdrmp 652080494 Jun 24... (3 Replies)
Discussion started by: sudhiroracle
3 Replies

4. UNIX for Dummies Questions & Answers

what is wrong with this command?

Hello, I try to using the below command to find out all the datafiles under "sja" direcotory. $ xargs -i find {} -type f -ls < sja /bin/ksh: sja: cannot open so can you tell me what is wrong? Thanks Jerry (3 Replies)
Discussion started by: GreatJerry
3 Replies

5. Shell Programming and Scripting

What's wrong with the following command?

Hi all, I'm trying to run the following command to get all files in one directory to another with the files' timestamps preserved, cp -p /logs/dvgbiau/batch/* /logs/dvgbiau/tmp_batch Note that ./batch and ./tmp_batch are two sub-directories under /logs/dvgbiau. The error was,... (1 Reply)
Discussion started by: isaacniu
1 Replies

6. Solaris

After command setenv auto-boot false machine's console not displaying

hi Alll, I want to install solaris 10 on exixting solaris mahcine. I tried for OK boot cdrom-install but it gave me fatal error - disk not bootable , boot command disable so i tried with ok setenv auto-boot? false Ok reset-all after this server rebooted automatically and... (2 Replies)
Discussion started by: sunray
2 Replies

7. Solaris

User account get locked due to strange behaviours

I am facing strange problem where after three failed login attempt user password must be locked. Actually what is happening, when I take the putty session of the server & enter user name on the prompt at the login prompt & then press enter to enter the password at this time when I checked the... (10 Replies)
Discussion started by: sb200
10 Replies

8. Shell Programming and Scripting

What is wrong with my awk command?

The below code usually works when the value for the COLUMN variable is numerical. but im in a situation where the number of fields in a file is not definitive. it changes. but what is static is that the value i want to retrieve from the log is 3 fields from the last field. which is what i... (9 Replies)
Discussion started by: SkySmart
9 Replies
FALSE(1)							   User Commands							  FALSE(1)

NAME
false - do nothing, unsuccessfully SYNOPSIS
false [ignored command line arguments] false OPTION DESCRIPTION
Exit with a status code indicating failure. --help display this help and exit --version output version information and exit NOTE: your shell may have its own version of false, which usually supersedes the version described here. Please refer to your shell's doc- umentation for details about the options it supports. AUTHOR
Written by Jim Meyering. REPORTING BUGS
Report false bugs to bug-coreutils@gnu.org GNU coreutils home page: <http://www.gnu.org/software/coreutils/> General help using GNU software: <http://www.gnu.org/gethelp/> COPYRIGHT
Copyright (C) 2009 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>. This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. SEE ALSO
The full documentation for false is maintained as a Texinfo manual. If the info and false programs are properly installed at your site, the command info coreutils 'false invocation' should give you access to the complete manual. GNU coreutils 7.1 July 2010 FALSE(1)
All times are GMT -4. The time now is 09:36 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy