Is it possible and, if yes, how to convert the following expression to one-liner? Simple DEV=${(lsblk -no KNAME,MODEL | grep ‘ModelNAME’)%%’ModelNAME’} doesn’t work Answer zsh allows you to combine parameter expansions. Bash does not. For either bash or POSIX sh (both of which su…
mmap does not work as expected (return random 0xdeadbeef)
I am writing c++ on linux7arm and the physical address is referring to a memory block (that can be accessed/changed by other peripherals) when I map a page of physical address space to the local address space and try to read it, it works fine and show the expected data BUT not all the time. if I write a scrip…
OS for Docker Image – Flavors
I’m very curious if most people are simply using Ubuntu for the majority of Linux flavors out there for their Docker images or if they’re using others. Can you tell me if you are using Ubuntu and if not why..and what else are you using? Is Ubuntu the defacto flavor just in general? Answer Many peo…
Reading tabular data from a line in bash [closed]
Closed. This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 7 years ago. Improve this question I need to check if the pin that user gives exists and if exists then display their names and…
Running a shell script for a certain duration
I want to be able to run a script on Linux shell (bash) for a certain duration and sleep for a different duration. I’ve written something like the following snippet. However, I see only the sleep happening correctly but the execution stops after first execution. The response I get is ./script.sh: line 3…
Parsing parameters with zparseopts, but from within a sourced script
I have a zsh script myscr.zsh, which sources another script zparse.zsh, like this: zparse.zsh expects a variable number of parameters, which do NOT need to be parsed using zparseopt, but zparse.zsh should – among other things – parse the positional parameters passed to mysrc.zsh. This is tricky, s…
Root autentication on a Python program
I have the root password saved in a variable. How I can give the root authorization at my program? This can be an example: Answer It is impossible to do it in the way you try. Your program is already started under some non-root user and you cannot change it inside this program. You can spawn other process whi…
zsh parameter expansion syntax: combining default value and conversion to upper case
In a zsh script, outputs the value of the variable X, or 4711 if there is none. outputs the value of the variable X, converted to upper case. I wonder, whether there is a way to combine the two, i.e. to have the effect of without introducing an auxiliary variable. Answer From man zshexpn: If a `${…}` ty…
SED : Remove last four characters from filename
I had list of files in the folder named test_images as below i want to rename all file by removing last four characters from each of them as How can i do it using sed ? Any suggestion will be appreciated. Thanks in advance 🙂 Answer if your file names don’t have spaces, you can: (under your test_images d…
Retrieving the memory map of its own process in QNX
In Linux if we look at the /proc/self/maps: I want information like pathname and starting address for Qnx. How can I get that information? My analysis says that there is not /proc/self/maps file in Qnx. Answer We have self file in QNX too !! The address space is represented by a binary file called “as&#…