I have the following directory structure: Each class contains the exact same directories, and the directories contain png files. What I want to do is copy the contents from dir1 to dir2 such that dir2 has the following format: For example: dir2/i/*.png should contain all the files in dir1/class1/i/*.png, dir1/class2/i/*.png, dir1/class3/i/*.png, etc… I have tried doing the following: But I
Tag: bash
Why is my envsubst command just inserting blank strings?
I’m trying to run the command envsubst < myfile to replace environment variables but instead of being replaced with their values, they are being replaced with blank strings. Here’s my example command (split onto separate lines for clarity): Here are my results: I’m clearly doing something obvious wrong, I just have a silly suspicion it’s one of those things that
how to use IF to test if a value meets a certain mask
I have a variable and I need to test if it contain a formated value like this ……..-….-….-….-………… the variable can contem any value in any format, and I need to test if the value is like 1572C097-4452-4495-8369-C7606F2C867E I tried using sed to retrieve the value from another variable But now, I dont have a clue how can I use
How can I run an argparse python program without the .py extension?
Currently, I have to type /xkcdpwgen.py -h in order to get the following usage: xkcdpwgen [-h] [-w WORDS] [-c CAPS] [-n NUMBERS] [-s SYMBOLS] Generate a secure, memorable password using the XKCD method optional arguments: -h, –help show this help message and exit -w WORDS, –words WORDS include WORDS words in the password (default=4) -c CAPS, –caps CAPS capitalize the
How to pass inputs (not arguments) thorugh command line in C/C++?
Say I have the following simple C++ program, and the following command in terminal: When I run this command, it will ask for my input and I have to copy and paste over the input like the following: Is there a way for this to happen in one pass? I don’t mind copy and pasting each time, however I am
I have three files and I want to count the concurrences from first 10 lines of the files and summation of it?
I Used this command to count the concurrences of the entire file. I need to find out the numbers of concurrences from only first 10 lines Answer You can use head to read only first 10 lines of the file. or just
How to run the bash script in parallel rather than sequentially?
Can someone please guide me I have the above script which is executed when we run the script for instance ./vmSetup.sh “1 2 3” but this is executed sequentially. I had created this script but now I want to run the cases in the script i.e. 1, 2 and 3 in parallel. Can someone also tell me how to run
Using awk in a bash-script
I’ve been struggling to run an awk result as the arguments of a new awk command within a bash-script; something like this To help eradicate (what I think is) inconsequential code to this problem, gives me and if prepend awk to this result, I get the answer I need. But I’m not able to make it work with xargs; it
How to auto insert a string in filename by bash?
I have the output file day by day: The date and time string, ex: 202105200900 will change every day. I need to manually rename these files to ( insert a short string x86 after date/time ) any bash script can help to do this? Answer If you’re always inserting the string “x86” at character #18 in the string, you may
Setup or env variable lost after running bash files
Please excuse me if there is an error in the sample code. There are two files testA.sh and testB.sh. testA.sh testB.sh deepak[18:33] $ ./testA.sh test b hello deepak[18:33] $ echo $a deepak[18:33] $ If we run any setup in the testB.sh then how can we use that setup or env variable in the main console (for example echo $a) Answer