Skip to content
Advertisement

Tag: while-loop

Restarting an endless while loop upon a mouse event?

I am aiming a simple code which looks like this: My goal here is to restart the print sequence from “hey 1” immediately when left mouse is clicked. However, I am not able to achieve this without using “if” conditions before every sleep. a “goto” is not working for me across different functions too. Can anyone suggest an optimal solution

grep -v with while read line command not working properly

I use this command to remove lines from (target.txt) that match string in (removefrom.txt) This is (target.txt) This is (removefrom.txt) This is the result should look like: But sometimes the resule is like: or or I ever try to use sed, but the problem is still there, It didn’t remove lines properly. Answer grep -vf removefrom.txt target.txt

How to build a conditional while statement in Bash?

Hello Stackoverflow community, In order to make my code as less ‘copy-paste-ey’ as possible, I’m trying to come up with a smarter method to make it more compact. Is there any way to create a ‘conditional while’-statement (if that’s even a thing) in your script without having to repeat everything over again? Basically, I have the same core function, but

Linux – auto restarting with sleep

Current code of mine is I don’t have access to a linux box right now and only way to do my request will be made on the live server and I don’t want to test and jeopardize something, so I would be happy if I could get some help Is this the way it should be if I want my

No return after executing passwd command using ssh in script

I have one script which reads hosts IP from /etc/hosts file, do ssh and update the passwords there for the given user. However, the script is closed after setting password for the first host and not able to set password for rest of the hosts. Please find below files- /etc/hosts file- 172.x.x.x host1 172.x.x.x host2 172.x.x.x host3 Script I am

How to know when dd has finished

I have a issue with the dd comand. I use it in a while like this: And it works like charm, the only problem is that once the file is read completely, it doesnt stop the while, it stays there stalled. How could I make the while to stop once the dd read all the file? BTW: Note my machine

Save all data into variable tcl

I have a code which i want to use to open a log file, extract the contents and save it into a variable so i can extract the data from the variable in the future. How do i do that? So far the code saves only the last data of the log file into the variable. I think the while

While loop not equal command not found

I am trying to perform a simple while loop comparing a variable to a string. It fails to load with the error on this line. Error states [: missing `]’ and : command not found. My while loop looks like; Answer There are a couple of errors: See that variable declaration do need to be like var=value. Otherwise, bash would

Advertisement