What is the purpose of a shell command (part of a shell script) starting with an exclamation mark? Concrete example: In foo.sh: I know that without the space the exclamation mark is used for history replacements and ! <expression> according to the man page can be used to evaluate “True if expr is …
Tag: bash
“mkdir || echo && exit” exiting even when mkdir succeeds
mkdir $2 || echo “I can’t create directory $2” && exit 8 Hi everyone, this is my first post here, so be kind. I am making a script right now and this line troubles me. The exit 8 should happen only if the directory $2 cannot be created. After running the script and successfully creat…
running python3 app at start up of Linux
I have the following script But the output is : the app has no problem running when I manually run it by typing python3 Server.py UPDATE: Clarification to the post I need the app to start running after the user pi logged in because it will need to get access to chrome Answer So after the previous comment was …
Extract a block from file between two lines
I have a file/output containing this : I would like to extract all public subnet id and print them without, and white space. I used this regex And the output is : But I would like to get this instead: In fact I told sed to replace spaces and newlines with nothing (s/[[:space:]]//g) and then it also replace th…
How to specify more inputs as a single input in Linux command-line?
I searched online but I didn’t find anything that could answer my question. I’m using a java tool in Ubuntu Linux, calling it with bash command; this tool has two paths for two different input files: What I’d like to do is for example, instead of specify the path of a single FASTQ, specify t…
Non-dash related bad substitution error
I am trying to write a bash script performing to find and pull somewhere else a specific file type. So far, I came up with the following script: find ./to_compress -type f -iname “*.tar” -mindepth 1 -maxdepth 1 -exec mv {} ./compressed/${{}##*/} However the bash complains that ${{}##*/} is a bad s…
BASH: How to add text in the same line after command
I have to print number of folders in my directory, so i use ls -l $1| grep “^d” | wc -l after that, I would liked to add a text in the same line. any ideas? Answer If you don’t want to use a variable to hold the output you can use echo and put your command in $( )
Extract fields from a custom xml
Im making a script to extract fields from a XML, now i got this and i need to make it work, i was trying with 2 for and greps and i need a little help with this i got this xml withs this fields and i want a output like this for make more comparations: Answer there are many issues
Why is my sed substitution with a & failing to execute?
I am trying to run following command on Linux Docker container but I am getting the following error: The file content I am running it for: I am doing it as suggested at – https://solveme.wordpress.com/2017/07/24/java-awt-awterror-assistive-technology-not-found-org-gnome-accessibility-atkwrapper-when-run…
Bash poweroff script hangs system
My intention is to cycle through my list of ips and poweroff if my ping succeeds first. However the systems seems to hang. After running this script I can’t ping the systems anymore and they aren’t powered off. If I run ssh 192.168.1.ip “sudo poweroff” through terminal I dont encounter…