Variables are case-sensitive, just like filename in Linux. Note the spaces around the square brackets. If the length of STRING is zero, $var is empty. I've just tested it. Our original tutorial needed correcting for the case if $var is null. These checks will report the array as empty, while it is clearly to interpolate all the array elements into a flat string, . The -n operator checks whether the string is not null. = != -eq -ne -ceq -cne, String comparisons. Add some more spice to make things uninterruptible: { trap "" INT while pgrep -fl May 19, 2010 In Bash you quite often need to check to see if a variable has been set or has a value other than an empty string. Or like this: Variable= 'Some string' # => returns error: "Some string: command not found" # Bash will decide that 'Some string' is a command it must execute and for variable echo ${Foo:-"DefaultValueIfFooIsMissingOrEmpty"} # => DefaultValueIfFooIsMissingOrEmpty # This works for null (Foo=) and empty string (Foo=""); 29 Jan 2014 That's sad because fish has a lot of advantages over bash to write scripts: cleaner and easier to remember syntax, good variables escaping, etc. 20 Feb 2007 The unary operator -z tests for a null string, while -n or no operator at all returns True if a string is not empty. In the man page it is written: while list-1; do list-2; done The while command continuously How can I test if line is empty in shell a line containing only whitespace should result in the empty string being assigned to i=0 while read -r line do I have the following bash script: while bash script while loop if variable is true. 1 Jun 2016 The Unix shell is often overlooked by software developers more familiar with higher level languages. For example, setting a default value read -p "Enter your name: " name : ${name:= John Doe} # if the user entered an empty string echo "$name" Variables · Functions · Interpolation · Brace expansions · Loops · Conditional execution · Command substitution · One-page guide to Bash scripting. the empty string is not equal to the four-character string true, I am trying to create a while loop in bash that won't continue until the user enters the word "next". 4 Bash Conditional Expressions. This script will give the I am using the while-loop to read a file. 18 Nov 2010 Brief tutorial describing how to do string comparisons. $ vech= $ vech="" Try to print it's value by issuing following command $ echo $vech. i want to find something in a string and replace with other string in bash and ksh how do i do string replace in bash script. (3) s1 < s2. This can be done using the -n or -z string comparison operators. I'd like it to if [ $1 ] && [ $2 ] then echo "Strings \"$1\" and \"$2\" are not null. Tables. (2) s1 does not match s2. You can define NULL variable as follows (NULL variable is variable which has no value at the time of definition); For e. trouble. Note: test is confined to integer values only. #!/bin/bash echo "OPTIND starts at $OPTIND" while getopts ":pq: If STRING is empty, Brief tutorial describing how to do string comparisons. 4 of the Bash User Manual, people!) It's everything to do with what happens to empty fields after Jan 28, 2014 One way to test for (non-)empty string is to use test and -z (-n). X=hello world # error An example is as follows: #!/bin/bash X="" if [ -n $X ]; then # -n tests to see if the argument is non empty echo "the variable X is not the empty string" fi. To preserve leading and trailing whitespace in the result, set IFS to the null string 22 Mar 2013 echo $STRING. Things to remember while using test If you are using square brackets [] instead of test, then care should be taken to insert a space after the [ and before the ]. Feb 20, 2007 The unary operator -z tests for a null string, while -n or no operator at all returns True if a string is not empty. Recently updated thanks to comments from our users. 19 Nov 2015 Glueing together APIs requires working with JSON: parsing it, extracting it, transforming it. In the following loop, opt will hold the value of the current option that has been parsed by getopts . Jul 2, 2015 The following bash script example we show some of the way how to check for an empty or null variable using bash: #!/bin/bash if [ -z "$1" ]; then echo "Empty Variable 1" fi if [ -n "$1" ]; then echo "Not Empty Variable 2" fi if [ ! "$1" ]; then echo "Empty Variable 3" fi if [ "$1" ]; then echo "Not Empty Variable 4" fi Feb 20, 2007 The unary operator -z tests for a null string, while -n or no operator at all returns True if a string is not empty. Note the empty pair of quotes after the -i: Bash by example, Part 2. 26 Aug 2005 Thus, for example, the following command would create three new, empty files named file1, file2 and file3: touch file1 file2 file3 For example, the -a option changes only the access time, while the -m option changes only the modification time. 3 Loop modifiers: break and continue. How could we achieve this?! The while loop has the solution. Whitespace is the set of blank characters, commonly defined as space, tab, newline and possibly carriage return. To determine if the value of a variable ($var) is empty (null):. . The second argument to getopts is a variable that will be populated with the option or argument to be processed next. Note: the < and > operators are also used by the shell for redirection, so you must escape them using \< or \> . What you want is to remove the spaces from the variable using the pattern replacement parameter expansion: [[ -z "${param// }" ]]. Expands to a string describing the version of this instance of If it is set while the shell is running, bash enables How can I determine the last line of "while read line"? If the input is a fixed string or file, since $lastline then might not be empty to begin with. The file has lines with null-terminated strings (words, actually. Unary expressions are often used to examine the status of a file. From the one-off grep search or sed replacement in your source tree to a more formal script for deploying 16 Mar 2014 If you do a Web search for 'linux delete blank lines' you'll find lots of command- line advice. Here we have another case of a mistake in one line causing a problem later in the script. An empty string evaluates to false inside the [ ] Arrays. If the line is empty, BASH_VERSION. (pgrep is in package psmisc IIRC). Effectively, this will return true for every case except where the string 10 Apr 2017 The while instruction is followed by the command from which to evaluate the return code to determine if it should loop or not. The following code will strip leading and trailing whitespace from the input: while read -r; do line=$REPLY done < text. OF=myhome_directory_$(date +%Y%m%d). Bash handles 25 Jun 2010 This is the quickest way I've found to search for and replace every occurrence of a string in multiple files in linux. Since running an empty command causes no error, it returns the corresponding return 12 May 2009 The following are examples of how you can test the various possibilities, and it works in bash or any POSIX-compatible shell: if [ -z "${VAR}" ]; then echo "VAR is unset or set to the empty string" fi if [ -z "${VAR+set}" ]; then echo "VAR is unset" fi if [ -z "${VAR-unset}" ]; then echo "VAR is set to the empty string" 9 Jan 2012 This is nothing to do with quotation marks making things that are already strings into strings, or some wrongheaded idea that = in bash 's built-in [ command is anything other than a string comparison. Changes in version 1. Variables may be given a null value by setting them to an empty string, e. Now that we explained the if , the while should be quite trivial isn't it? 27 Aug 2017 above, I have checked if both strings are not null then execute the echo command. For example 22 Sep 2015 Using while Loop to Read Input from User Now, consider a case wherein we need to repeatedly prompt the user to enter a line of input. Dec 6, 2012 My shell script depends upon user input. We have updated our original article. "null" is never helpful, so I'll Here is a set of small scripts, which demonstrate some features of bash programming. Your backup script and variables: #!/bin/bash. dat} Echo the value of variable datafile if it While [[ is a builtin expression, so aruments do not need quoting. (3) __ TO-DO__. 4 of the Bash User Manual, people!) It's everything to do with what happens to empty fields after 6 Dec 2012 My shell script depends upon user input. (5) -n s1. Fig. Some of If AWK finds no field separators at all or no strings between field separators, as in the three blank lines in our sample, then NF in those lines is zero, and the lines are ignored because no fields were found. The output of ls is a simple string, and Bash treats it as such. Learn how to use it by getting your hands dirty with a JSON blob that represents the open issues in the public Docker GitHub repository. A string is already an object much as it may be empty while null simply means non- existence of an object. g. / | xargs sed -i 's/windows/linux/g' Bash Shell Script to check if a string has only alphabets and digits. While bash does make it difficult to run SUID, it's still possible on some platforms which is why we're being explicit about banning it. In a feature unique among many languages, bash can operate on the value of a variable while dereferencing that variable. Conditionals. (4) s1 > s2. Setting up a bash script; Basic bash scripting with variables and control flows; Storing the output of execution with sub shells; Loops and iteration; Mastering your bash environment . [string] | gm - while [ $var -lt 10 ] do echo $var var=$(( $var + 1 )) done, $var = 0 while ($var -lt 10) { echo $var $var++ }, Prints numbers 0 through 9. 2, quoted strings and substrings # bash while loop while [ $choice -eq 4 ]; do # read user input read choice string s1 is not empty-z s1: string s1 is empty #!/bin/bash #Declare string S1 S1="Bash" You can use if statements without any brackets or within [] or [[]] or (). 6. Check that they are as you expect. Conditional expressions are used by the [[ compound command and the test and [ builtin commands. echo $foo . JQ is a fast, lightweight, flexible, CLI JSON processor, that does the job well. 2: since 3. 2 The for … do … done loop statement; 11. However, the original (empty) value is restored after executing that command, so the echo statement afterwards prints an empty string for the value of MYVAR . There are string operators and numeric comparison operators as well. set breaktheloop 0 while How to determine if a bash variable is empty? while "$var" will always be The question asks how to check if a variable is an empty string and the best answers Check if array is empty in Bash. bash while string is emptyI'd do while pgrep -fl "mylittleprogram"; do sleep 6; done exit # process has ended. One way to test for (non-)empty string is to use test and -z . More bash programming if myvar is the empty string, it's time to introduce two other bash looping constructs, "while" and "until". if [ -z "$string" ]; then echo "String is empty" elif [ -n "$string" ]; then echo "String is not empty" fi Reading lines. ) Because BASH internally uses C-style strings, in which '\0' is the terminator, read -d $'\0' is essentially equivalent to read -d '' . Referring to an uninitialized variable is identical to having it initialized to ''. Leave this field empty if you're human: In this section of our Bash Scripting Tutorial you will learn the The lengh of STRING is zero (ie it is empty). What happens is the shell keeps looking for the closing quotation mark to tell it where the end of the string is, Strings. The executed statement is called the loop body. (4) __TO-DO__. #!/bin/bash # needs to be debugged Rand_String=$1; if test $Rand_String = " Bash not equal string comparison #!/bin/bash while [[ "$(ipcs | awk ' Bash Script verify user input is not empty and is equal to a value: Bash Script Replace Empty Spaces String; Bash / KSH: Define Delimiter (IFS) While Using read Command; Bash Shell: Find Out If a Variable Is Empty Or Not; Oct 29, 2012 · If / Else Statements (Shell/bash Scripting) Shell scripts use fairly standard syntax for if Linux shell/bash check if string is empty or not In reply to DaveVanHandel; Any bash test without an argument will return true Test if file is empty bash. txt | while read line; do echo $line done As you can see, the quotes around the "$1" protects the spaces to keep the '-n' test from complaining (it's a binary test, and would hate more than one argument) and the test will return false on empty strings, which will abort the while loop. If you have ever . fi non-empty Different shells (Bash i want to find something in a string and replace with other string in bash and ksh how do i do string replace in bash script. set breaktheloop 0 while This is all great stuff - just made it into a script so I can check for empty directories below the current one. expands to one argument, with all args joined # by (usually) spaces, # so no args provided will result in one empty string # being passed on. Use sudo to provide . Effectively, this will return true for every case except where the string What you want is to remove the spaces from the variable using the pattern replacement parameter expansion: [[ -z "${param// }" ]]. Bash will complain if the spaces are not there. 27 Jan 2014 This article shows examples of how to use BASH if statements in scripts and command line. How to make the argument as optional in bash? <<<"some string" feeds in only "some string" as tests if the second parameter is non-empty. The below should be put into a file called 'findempty Testing for (non-)empty string in shell Bash test empty string. (6 ) s1 is null 6 May 2014 IMHO, this should be the default for raw-output mode. It's generally best to set 17 Oct 2012 declare -A MYMAP # Explicitly declare $ MYMAP[foo]=bar # Or this line implicitly makes it an associative array (in global scope, bash 4. X=hello world # error #!/bin/bash X="" if [ -n $X ]; then # -n tests to see if the argument is non empty echo "the variable X is not the empty string" fi. 01: Bash scripting various way to Jan 9, 2012 This is nothing to do with quotation marks making things that are already strings into strings, or some wrongheaded idea that = in bash 's built-in [ command is anything other than a string comparison. This can be done using the -n or -z string The following bash syntax verifies if param isn't empty to detect a string which is either empty, #execute if the variable is empty or contains How do I find out if a variable called $_JAIL path is empty under a Linux After a while, Bash Script Replace Empty Spaces String; Bash Shell Script To Test How to determine if a bash variable is empty? while "$var" will always be The question asks how to check if a variable is an empty string and the best answers I'm wondering how the while loop evaluates its loop condition. Example two:. How do I find out if a variable called $_ JAIL path is empty under a Linux / Apple OS X / Unix like operating systems? Pass the -z option to the if command or conditional expression. Listing 2 shows more examples of string tests. (6) -z s1. , are defined and have non-null values) and set default values for variables and catch errors that result from variables not . This expands the param variable and replaces all matches of the pattern (a single space) with nothing, so a string that has only spaces in it will be expanded to an empty string. Note: the < and > operators are also used by the shell for redirection, so you must escape them using \< or \> . Nov 18, 2010 Brief tutorial describing how to do string comparisons. It expects minimum 15 characters and does not work for anything less than 15 chars. This works as expected and replaces all blanks in the 10 Mar 2008 if [ $1 -eq NULL ] && [ $2 -eq NULL ] then echo "Parameters doesn't have a value ($1 and $2)" else echo "$1 and $2 has a value or check failed" exit 1 fi. Simple example of while. How do I find out if a variable called $_JAIL path is empty under a Linux / Apple OS X / Unix like operating systems? Pass the -z option to the if command or conditional expression. I've tried to . function parameters) this calls the function. You can ensure that variables exist (i. > String lexiographic comparison (after). Here we only used '-n' parameter but we can also use “-z“. gz . 52 KB while inputString is not empty-string token = GetToken (inputString)-if How to check the length of a string in Bash or get the length of a variable if it stores some string. If the "while read" is replaced with any other kind of loop, Variable inside bash's while loop never How to check the length of a string in Bash or get the length of a variable if it stores some string. "Tue May 26") \D{format} the format is passed to strftime(3) and the result is inserted into the prompt string; an empty format results in a locale- specific time //Logs string to console. Decimal values are while I have quotes in my example, they are not always necessary. The input should be written to a file. My loop is currently while [ -n "$RAW" ]; do // do some processing here RAW=$(echo $RAW| sed -r 's/^. Quoting the variable is required so that the test will have Testing for (non-)empty string in shell Bash test empty string. if [ "$var" == "" ] then echo variable I'm trying to set up a script that parses a string. (1) s1 = s2. http://www. This is unfortunate because the shell can be one of the most important parts of a developer's toolkit. That is why, in the second example, only the first two arguments If no <NAME> is given, the whole line read (without performing word-splitting!) is assigned to the shell variable REPLY. In those cases, bash treats the variable as empty, equivalent to the empty string. The use of Partial date-time strings can be used. Allen 3 Using correct indentation in shell scripts; 4 The test helper program – file tests, string tests, and integer expressions 11. 11. The above condition is true if $ emptystring is an empty string or an uninitialized variable. (1) s1 matches s2. where you need quotes is when your variable names include spaces. For this reason, when you redirect the out of the echo command above into the file, and view the file contents using the cat The while loop has a variant called until which simply reverses its check; and the for loop can appear in two different forms. To determine if the value of a variable ($var) is empty (null): Bourne/bash shell scripts: string Bash loops are very useful. This is a good starter tutorial for those who haven't quite mastered BASH yet. raw download clone embed report print Bash 0. log >/dev/null; then echo non-empty; else echo "fine :)"; fi non-empty. Ian! D. loops++; //Adds 1 to loops /*All this should be in the while loops braces*/. Bash string Variables in bash script. 1 The while … do … done loop statement; 11. 01: Bash scripting various way to The following are examples of how you can test the various possibilities, and it works in bash or any POSIX-compatible shell: if [ -z "${VAR}" ]; then echo "VAR is unset or set to the empty string" fi if [ -z "${VAR+set}" ]; then echo "VAR is unset" fi if [ -z "${VAR-unset}" ]; then echo "VAR is set to the empty string" Jan 9, 2012 This is nothing to do with quotation marks making things that are already strings into strings, or some wrongheaded idea that = in bash 's built-in [ command is anything other than a string comparison. set x 0 while math "$x<10" > /dev/null echo $x set x (math "$x+1") end. 30 Sep 2011 printf 'a\tb\rc\nd\0e' | while IFS= read -r -s -d '' -n 1 char do if [[ "$char" == '' ]]; then echo -n "-NULL-" elif [[ "$char" == $'\r' ]]; then echo -n "-RETURN-" elif If the -d is not included then NEWLINE will also return an empty string (as a delimiter) in which case the result is a-TAB-b-RETURN-c-NULL-d-NULL-e 10 Mar 2014 While shell scripts can be used for more complex tasks, they are usually not the best choice. To consider the counterexample, when would it be useful for raw-output to output "null" to stdout instead of an empty string? To give my use case, I'm using raw-output mode to extract command line arguments for bash scripts. You could Bash: when an empty IFS does not work like a default IFS (info) one has to set IFS to an empty string: Code: That's a problem with the while loop, index=0 while [ "$index" -lt #!/bin/bash # empty-array. Different If AIX crashed with a 50'000 lines, it may scale up to millions of lines in recent Linux's – but still use trucks of memory. This is why I 14 Nov 2014 It's sometimes useful to allow parameter expansions side-effects to occur. you get different results between raw download clone embed report print Bash 0. (Read § 6. "" | gm, Get a list of non-static string members. Filed under: so we have define an empty backup file. while getopts ":ht" 6. 01: Bash scripting various way to 28 Jan 2014 One way to test for (non-)empty string is to use test and -z (-n). The syntax of a while loop is as follows:. Thus, to modify the PATH variable variables and arrays;; operations on variables;; subtle quirks like * versus @;; arithmetic;; strings;; scope;; files and redirection;; pipes;; processes;; patterns;; control structures;; pitfalls. 4: Sorry for the many releases! #397: Tokens after a here string start were not always detected properly; Index version increased to 4 Jan 2015 For example, the string 'ht' signifies that the options -h and -t are valid. Btw, im guessing theres differences when writing to a Kourne or Bash shell. biz/faq/unix-linux-bash-script-check-if After a while. You could redirect the output of pgrep to /dev/null if you wanted the waiting to be silent. As mentioned earlier, BASH provides three types of parameters: Strings, Integers and Arrays. lang. 20 Feb 2014 While most distributions provide sensible defaults for the styling of user and root prompts, it can be helpful to customize your prompt to add your own . The only difference is that with '-z', it searches for string with zero length while “-n” 24 Jul 2009 While step 1 was rather quickly done im facing trouble with putting the blanks back in Here is what im currently doing : Code: #!/bin/bash Org="Original searchstring !" RepBy="_**_" RepPatt=" " RepOrg="${Org//$RepPatt/$RepBy}" / bin/echo $RepOrg. The conditional expression is meant as the modern while the same primitives and its behaviour changed in Bash 3. $ x=foo $ test -z "$x" if grep ORA- alertDB01. Bash parameters and parameter expansions. If you test this script, In this script, the field separator is specified within the code itself (by setting the FS variable), while our previous example set FS by passing the -F" :" option to awk on the command line. cyberciti. txt . log >/dev/null; then echo non-empty; else echo "fine :)"; fi non-empty. while hungry ; do eat_cookies done. Strings are without a doubt the most used parameter type. Example: echo ${datafile:-mydata. This should continue as long as the user enters non-empty string. Expressions may be unary or binary. sh # Thanks to Stephane Chazelas for the Bash supports string vector operations #+ if the result is a I have a daemon that can be run manually from a bash shell Passing an empty string as a commandline argument using a and instead of an empty string the daemon The syntax for a while loop in bash is Code: while [ condition ] do <commands> done but what is the equivalent for the c-style Code: do { <com Replace strings in files with sed, the bash command . echo -n "Please choose a word [1,2 or 3]? " # Loop while the variable choice is equal 4 # bash while loop while [ $choice -eq 4 ]; do # read user input while I have quotes in my example, they are not always necessary. =~ String regular expression match (bash 3 only, not currently . NoClassDefFoundError: BashIcons. tar. #398: Error updating LexerEditorHighlighter, resulted in many error while working in a Bash script. test="test" $ homedir='pwd' string="The man said \" hello \". /trouble. {0,15}//') 19 May 2010 In Bash you quite often need to check to see if a variable has been set or has a value other than an empty string. So in the () of the . bash: line 10 syntax error: unexpected end of file. if [ -z “$emptystring” ]; then. 13 Apr 2017 shift , while , do , done , case , esac. $ x=foo $ test -z "$ x" if grep ORA- alertDB01. (2) s1 != s2. a array element count (BASH or ZSH) if [ ${#var[@]} -eq 0 ]; then echo "Variable undefined, or Array is Empty" elif [ "X$var" = "X" ]; then echo "Variable is a NULL string" else echo "Variable replacement and should be used for string comparisons, while ((. Nothing will be shown because variable has no value i. Most of the time you only need to know if a variable is set to a non-empty string, but occasionally it's important to distinguish between unset and set to the empty string. Bash: String Length – How To Find Out. for ((i=0; i < 10; i++)) do 5 Jan 2015 Whenever you pass the "" string to the print command, it prints a blank line. Create a Bash script which will accept a BaBE - Bash by Examples; uname -m | while read arch; empty strings . #399: Potential fix for java. Here's a (( i-- )) > done $ for (( i=10; i > 0; i-- )) > do echo "$i empty cans of beer. In this section of our Bash Scripting Tutorial we'll look at while loops, The list is defined as a series of strings, bash: variable loses value at end of while read loop. Set the while condition to be loops <3. For example,. {15 In Bash you quite often need to check to see if a variable has been set or has a value other than an empty string. Try this: RAW=$( echo $RAW| sed -r 's/^. datafile= . #!/usr/bin/bash # test_name while : do echo -n "Enter customer name :" read NAME [ check_length $NAME 10 ] && break echo "The string $NAME is longer then 28 Jun 2010 Looping statements are used to force a program to repeatedly execute a statement. 25 Nov 2012 If you use bash for scripting you will undoubtedly have to use conditions a lot, for example for an if … then construct or a while loop. bash while string is empty (5) s1 is not null (contains one or more characters). Example of each syntax is given below: If statement without any brackets: Linuxtopia Books - Advanced Bash Shell Scripting Guide - Manipulating Strings . <, String lexiographic comparison (before). if [ "$var" == "" ] then echo variable 11. It proceeds if the return value is 0 . I can't seem to figure out how to use strings for the condition Check if array is empty in Bash. " echo "number of array elements "$n arr[10]=h n=${#arr[@]} echo "number of array elements "$n echo ${arr[10]} echo ${arr[4]} # empty string echo ${arr[6]} # empty string if some_stuff ; then # A statement is required here. 1 String comparison operators. 25 Nov 2008 -print0 | while read -r -d $'\0' x; do (Some other commands, including sort and xargs , have options to make null character the delimiter based on the same reason. 2+ only) $ MYMAP[baz]= quux # Can add multiple values one by one $ MYMAP[corge]=grault $ declare -A MYMAP=( [foo]=bar [baz]=quux [corge]=grault ) # Initialise all at 22 Mar 2012 Placing a colon (:) before the operator character in these constructs has the effect of counting a null value the same as an undefined variable. if [ "$var" == "" ] then echo variable I'd do while pgrep -fl "mylittleprogram"; do sleep 6; done exit # process has ended. bash: line 8: unexpected EOF while looking for matching " . grep -rl matchstring somedir/ | xargs sed -i 's/ string1/string2/g example: grep -rl 'windows' . ) What I have by that reading - just a first word up to '\\0'! I need to have whole string up. So I decided While. 3 Feb 2014 It is not ending because the sed expression is not correct. 1 Dec 2016 Note: You should keep in mind that an empty string is not the same as null. In BASH, be sure the strings litereals are in quotes. They behave identically unless quoted with " , in which case $@ splits each argument into a different word, while $* becomes a single string, with each If you are using bash, you can have other arrays. The loop function doesnt have any parameters so it is left empty and called like this loop() typing loop wont do anything. Loops execute until the v. These checks will report the array as empty, while it is clearly to interpolate all the array elements into a flat string, If the length of STRING is zero, $var is empty. # (Consult 'man bash' for 27 Apr 2017 #!/bin/bash # Script to see if the variable holds value or not var1=" " var2= linuxtechi if [ -n $var1 ] then echo "string is not empty" else echo "string provided is empty" fi. cat file. 52 KB while inputString is not empty-string token = GetToken (inputString)-if Examples of while loops in bash scripting or shell programming. The ${VAR+foo} construct expands to the empty string if VAR is unset or to foo if VAR is set to anything (including the empty string). e. The syntax of these conditions can seem . Bash While Loop Examples . fi non-empty Different shells (Bash How to determine if a bash variable is empty? while "$var" will always be The question asks how to check if a variable is an empty string and the best answers How can I determine the last line of "while read line"? If the input is a fixed string or file, since $lastline then might not be empty to begin with. a blank or a comment # isn't enough! else einfo "Not some stuff" fi String inequality