Skip to content

Tag: shell

Echo only valid user

Bash newbie question: I’d like to have this script echo out only users from a given list that are valid user IDs, and not echo the invalid ones. Here’s what I have so far: Instead, it is echoing out the results of ‘id’ as well as the text “is not valid user ID” Ideally, it&…

How to run command CTRL+Z in Shell?

I have a Node progress. I want to auto-start it and keep it in background via a shell script. The way I keep background progress is press crtl+Z after run npm run start, then run bg && disown. Now I’ve got a problem: How to process this crtl+Z command in Shell script? Answer Another way to run a…

Use bash -s with other arguments

I have install.sh script which is located in server. I want to write one line code to download and run the script. Everything works fine until I am trying to set arguments It can’t recognize ‘-p’ as an argument but ‘abc’ can. How to set arguments in this situation starting with &…

Why does flock removes existing text from a file?

So, I am trying to get an exclusive lock on a text file using Flock and a line of text to that file however while doing so it removes whatever text was there earlier. So if the file had let’s say and after running the script I am expecting something like instead, all I get is why would it behave