I'm facing the problem with below code set with usage of {},
i want to use {} instead of (), as i don want bash to fork a new shell.
Source :
If you invoke the exit in a subshell, it will not pass variables to the parent. Use { and } instead of ( and ) if you do not want Bash to fork a subshell.
But the ouput is :
i want the "exit" inside {}, should exit the script execution.
You haven't said what OS and shell you're using, so you should also be aware that the way echo behaves when its 1st argument starts with a minus sign (as in your code) or has any argument that contains a backslash character, varies from operating system to operating system and from shell to shell. For portable code, printf would be better than echo as in:
This User Gave Thanks to Don Cragun For This Post:
It wants a space (or a newline) between { and echo.
Further a leading - can mean an option to the echo command, and the shell evaluates the text and might stumble on a ..
The following fixes it:
This User Gave Thanks to MadeInGermany For This Post:
Hi,
Could you please let me know, why we should not use '.' in move command, if we use it, is it something wrong.. Please share the details on it.
/home/rahualux/emp.csv /home/rahualux/details/employee_files/.
Or other example for mutlipile files
/home/rahualux/*.csv... (3 Replies)
Hi
I have a file called tmp with the content as belowmore tmp
NAMELIST(Hari)
NAMELIST(Raju)
I want to get the values between the brackets.
When I executed the below command on zlinux I get the output which I wantedmore tmp |awk -F'' '{print $2}'
But when I execute the same in... (3 Replies)
I am trying to output a log file from cp usage. I think this can be achieved. In my code I have this.
cp -i -v ~/files/* ~/backups/oldfiles/;; > ~/logs/logfile.logThe error I get is "syntax error near unexpected token '>'
What am I missing? (7 Replies)
Hi all,
Can you please tell me the command, with which one can know the amount of space a specific directory has used.
df -k . ---> Displays, the amount of space allocated, and used for a directory.
du -k <dir name> - gives me the memory used of all the files inside <dir>
But i... (2 Replies)
This is the code:
while test 1 -eq 1
do
read a
$a
if test $a = stop
then
break
fi
done
I read a command on every loop an execute it.
I check if the string equals the word stop to end the loop,but it say that I gave too many arguments to test.
For example echo hello.
Now the... (1 Reply)
how can I find cpu usage memory usage swap usage and
I want to know CPU usage above X% and contiue Y times and memory usage above X % and contiue Y times
my final destination is monitor process
logical volume usage above X % and number of Logical voluage above
can I not to... (3 Replies)
Hi,
I have just written a script in /bin/bash, however, l want to test if character is a carriage return or space. Also l want my script to be able to detect my disk space and send a mail if usage is more than 90% or send an alert.
Thanks
Kayode (6 Replies)