Skip to content
Advertisement

Tag: bash

Copy files to another directory containing the same directory structure in bash

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

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

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

Advertisement