Argument Expected Error In Shell Script
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about korn shell test argument expected hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges
Bin Zipgrep Test Argument Expected
Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. relink test argument expected Join them; it only takes a minute: Sign up getting Error ksh[7]: test: argument expected up vote 0 down vote favorite When executing the below line , am getting the error ksh[7]: test: argument expected while [ $cont =
Too Many Arguments Error In Shell Script
"y" ] Whats wrong with this line? shell share|improve this question edited Jul 2 '13 at 13:33 Holger Just 26k65680 asked Jul 2 '13 at 13:29 user2519862 add a comment| 1 Answer 1 active oldest votes up vote 1 down vote accepted $cont might not be set, which is why it fails. Enclose the variable in double quotes like this: while [ "$cont" = "y" ] share|improve this answer answered Jul 2 '13 at 13:34 dogbane 136k42235322 unary operator expected error in shell script I have set it as cont="y".. So what shuld be wrong then? –user2519862 Jul 2 '13 at 13:35 Its working fine now, after adding the double quotes as u suggested.Thanks a lot!!! –user2519862 Jul 2 '13 at 13:37 add a comment| Your Answer draft saved draft discarded Sign up or log in Sign up using Google Sign up using Facebook Sign up using Email and Password Post as a guest Name Email Post as a guest Name Email discard By posting your answer, you agree to the privacy policy and terms of service. asked 3 years ago viewed 5760 times active 3 years ago Related 774How to mkdir only if a dir does not already exist?577How to set a variable equal to the output from a command in Bash?470Check existence of input argument in a Bash shell script0Too many arguments error in shell script0What -a argument do in ksh?1Bad substitution error in ksh0Shell script too many arguments error [unable to resolve with using quotes]1Unexpected error in KSH0Shell script Error : Conditional biinary operator expected1Test : Argument Expected Hot Network Questions How do I deal with players always (greedily) pushing for higher rewards? Why did companions have such high social standing? Repeating pattern X amount of times in LIKE Least Common Multiple How to deal with a very weak student? Generate SQL UPDATE from Excel CSV file Verb
& Answers This forum is closed for new posts. Please post beginner questions to learn unix and learn linux in this forum UNIX
Binary Operator Expected Error In Shell Script
for Beginners Questions & Answers Search Forums Show Threads Show Posts Tag
Integer Expression Expected Error In Shell Script
Search Advanced Search Unanswered Threads Find All Thanked Posts Go to Page... unix and linux commands - unix unix shell script argument shell scripting Test: argument expected error in shell script UNIX for Dummies Questions & Answers Thread Tools Search this Thread Display Modes #1 03-06-2012 snvniranjanrao Registered User http://stackoverflow.com/questions/17426944/getting-error-ksh7-test-argument-expected Join Date: Nov 2009 Last Activity: 6 March 2012, 12:29 PM EST Posts: 4 Thanks: 0 Thanked 0 Times in 0 Posts Test: argument expected error in shell script Hi, I am trying to write a small script that validates if there exist files that start with a pattern in a given directory. Below is the piece of my script: Code: #!/usr/bin/ksh http://www.unix.com/unix-for-dummies-questions-and-answers/178311-test-argument-expected-error-shell-script.html BTFDIR=/opt/ships/temp if [ -e ${BTFDIR}/btf_daily_file_summary*.dat ] then echo 'found' else echo 'not found' fi When I run this script, I am getting "test: argement expected" error when I execute it in current shell. However, when I execute in a new shell, it is giving me expected result as below. Quote: $ test.sh ./test.sh[3]: test: argument expected not found $ $ sh test.sh found Here are my questions in this regard: Why is this script behaving differently in these two scenarios? What should I change to fix this issue? Is there any better way to achieve this requirement? Moderator's Comments: Do not post technical questions in the "contact mods and admins" forum. Thread moved. Remove advertisements Sponsored Links snvniranjanrao View Public Profile Find all posts by snvniranjanrao #2 03-06-2012 balajesuri #! /bin/bash Join Date: Apr 2009 Last Activity: 29 September 2016, 11:36 AM EDT Location: India Posts: 1,957 Thanks: 30 Thanked 565 Times in 541 Posts Quote: Originally Posted by snvniranjanrao I am trying to write a small script that validates if there exist files that start with a pattern in a gi
the same would fail with the ‘test: argument expected' error if you try to execute it under sh on Solaris platform. #!/usr/bin/sh touch http://nirbhay.in/blog/2012/12/shell-test-argument-expected/ /tmp/i_exist if [ -e /tmp/i_exist ]; then echo "file exists!" fi So, what we are trying in the above script is to check if the given file exists using shell's [condition]. As per Solaris test(1): … -e file -- True if file exists. (Not available in sh.) … A simple solution to this issue is to use ‘-f' instead. It checks shell script for the existence of regular files and supposed to work on most of existing shell interpreters. Share this:TwitterFacebookGoogleLike this:Like Loading... ErrorShellSolaris Post navigation Previous Postxkcd on RNG :)Next PostShell script: recursive find/replace 3 thoughts on “Shell: test: argument expected” Andrew says: April 20, 2013 at 6:47 am Thanks! I was working on a backup script, and this fixed the problem error in shell I was having! Reply admin says: April 21, 2013 at 11:27 am glad to hear! Reply Kavya Kulshreshtha says: February 11, 2014 at 10:39 pm that worked..thanks!! i have two linux servers, on one -e works , but on other it doesnt server_A: Linux server_A 2.6.32-131.0.15.el6.x86_64 #1 SMP Tue May 10 15:42:40 EDT 2011 x86_64 x86_64 x86_64 GNU/Linux server_B:Linux server_B 2.6.32-131.0.15.el6.x86_64 #1 SMP Tue May 10 15:42:40 EDT 2011 x86_64 x86_64 x86_64 GNU/Linux Reply Leave a Reply Cancel reply Your email address will not be published. Required fields are marked *Comment Please enable JavaScript to submit this form.Name * Email * Website Notify me of follow-up comments by email. Notify me of new posts by email. the informal blog Recent Posts Systemd: Managing multiple MariaDB instances Reading MariaDB/MySQL binary log files in Go Capturing MySQL packets Donor selection in a Galera cluster Securing MariaDB Galera Cluster using SSL TagsAjax C C11 Cluster Cplusplus CPP Debian Debugging Encryption Error Fun Galera gcc GDB Go Golang Goroutines HTML5 Interview Java Javascript JDBC Jquery Linux Logger MariaDB Multithreading MySQL OpenSSL OS Problems Progra