I have a script test.sh He has some arguments like : I made a while read loop to replace each specific part of a line (extractReplaceArgLine) with argument passed in shell script (Forest Cuba World Hello). Consider the file test.txt : So, the output would be : How can I do that ? Thanks ! Answer Use $1 to get
Tag: linux
How can i link the mounted folder to Laravel project?
I have a Laravel project, which placed here: We attached a new storage to vds and mounted it for folder. After that we need add symbolic link from /home/user/www/storage to /home/user/www/example.com/storage , but we can not do it, because the last one is already exists and contains needed files. How can we l…
Why does bash go into an infinite loop?
I was trying out different ways of emulating a boolean variable in bash. One method is: which prints true and false respectively. Then I had a brain cramp and typed: expecting to see yes in the terminal. However, without the echo command, it went into an infinite loop printing y. Can someone explain what bash…
Extracting group from regex
I am new to using regex and having some issues understanding how to extract a group from a regular expression. I have a text file (example.txt): I am trying to extract the “5.2.1” only from the libpackage line and put it into a variable for a bash script. I have tried doing But it gives me the ent…
How to keep telnet connection alive from client side
I have a device as a telnet server but drops the connection if no packet is received in 60 seconds, for some reason this behavior cannot be changed. Putty has a feature to send null packets to the server periodically to keep the session alive, which works fine for me. But some times I have to telnet to the de…
Sed to search regex pattern and remove line with above pattern
this is my file.txt content. Here I’m trying to search pattern text: ‘About’ and remove items:[{ line with the command as below: file.txt: Command: sed -n -i -E ‘/text: ‘About’/{n; $p; x; d}; x; 1!p; ${x;p;}’ file.txt but it seems to be not working. Is there any way t…
How to let the python script (abc.py) keep executing on AWS even after Connection lost or SSH connection is terminated?
I was using Jupyter notebook on AWS AMI and using the port forwarding on Windows using PuTTY. I got my connection terminated and all the work of 24 hours is lost now and I’m unable to get that. So I used a script instead of Notebook and the same thing happened. I used to think that the process would kee…
Python Subprocess ping -h Returns Exit Status 2
I want to capture ping -h output using Python, it results in exit status 2. I am working on a Linux host. This is the output The command seems to execute normally on the shell. What is the cause of this error? How can I fix it? Answer Following Barmar solution It is a normal behavior for ping, but the
how read/reach/access a file from Kotlin when the application is deployed either in Kubernetes or Linux
Context: I successfully parse a json file while debugging/running locally in my Windows PC that way When I deployed it to either docker or AWS I get this error Is there a more reliable way to “navigate” to a file placed in resources folder? I mean someway it wouldn’t be affected either it is…
How to find all the files created today and modified anytime before 5 minutes?
Let’s say it is 10:00 am when the command is run, I need to list the files modified between midnight and 9:55 am. I have tried the following command which looks logical as per the documentation but it is pulling all the files since yesterday. Answer Since -daystart isn’t that portible, consider a …