I am trying to read a text file (line by line) and take user response in a while loop. However, the script does not wait to take input. Instead, it just prints all the text to screen. The script only prints alternate text lines from the file (Please refer to the image below). Output Answer This worked for me:
Tag: bash
Bash escape character
I have this very reduced example of a bash command, where I want the $ sign escaped. So the command : should print out: a simple $test does not work unfortunately. I tried lots of other stuff but still couldn’t find a solution. Any suggestions ? Answer Put it in single quotes rather than double quotes. The single quotes keep
How to get audio length for all audios using sox?
I can do soxi -d * to get audio length information in hours, minutes, and seconds. However it would only give me info on the individual audio length. If I wanted to see the audio length for the entire folder, how can I accomplish such task? like when you do “wc -w” it shows the sum of everything at the
bash – print regex captured groups
I have a file.xml so composed: I need to extract the following information: mayor_and_minor_release_number –> 1.0 patch_number –> 13 suffix –> -alpha I’ve thought the cleanest way to achieve that is by mean of a regex with grep command: I’ve checked with regex101 the correctness of this regex and actually it seems to properly capture the 3 fields I’m looking
Move a file and rename it if the destination folder contains also a file with the same name
Sorry for my bad english. I want to move a file from the Desktop to user’s input destination. If destination has also a file with the same name, how can i ask user to rename the file so that he can have them both in destination folder? I have this right now: Answer Demonstrating using mv and switches -i (interactive)
using awk to count the number of occurrences of pattern from another file
I am trying to take a file containing a list and count how many times items in that list occur in a target file. something like: I have coopted the following code to get the values that are present in target.txt: But the output does not include the desired items that are in the liist.txt but not the target.txt I
how can i echo a line containing single quotes?
I want to echo a line containing single quotes but when I am echoing it, the output comes out without the quotes inside that line. I am using this echo rule_files: [ ‘${path.config}/folder/*.py’ ] and the output is rule_files: [ ${path.config}/folder/*.py ] I want the output to include the single quotes around the path. Answer You have to escape the
Save multiple docker images using one command
Currently I am exporting docker images using below command docker save imageName | gzip > imageName.tar.gz docker save mysql | gzip > mysql.tar.gz This command working fine for single image, i have tons of docker images in my local system, want to export. but i don’t know how to export all images which is available in docker images. Please guide
How do I pass “>>” or “<<" to my script without the terminal trying to interpret it as me either appending to something or getting stdin?
My python script can take a series of bitwise operators as one of its arguments. They all work fine except for “=<<” which is roll left, and “=>>” which is roll right. I run my script like ./script.py -b +4,-4,=>>10,=<<1, where anything after -b can be any combination of similar operations. As soon as the terminal sees “<<” though, it
Executing bash shell script accepting argument and running in background
I have written a shell script run.sh to trigger a few tasks based on the user’s input The tasks 1,2 … 6 are php scripts that are run like /usr/bin/php task1.php $TIME with $TIME as an argument for the php script etc… The script runs fine when I type bash run.sh but since tasks 1-6 takes a long time to