Skip to content

Tag: bash

Repack tar.gz to tar and exclude some files

I have a big backup.tar.gz file (260 GB) and about 160 GB of free storage space. Backup file contains three big dumb file (old backups, about 190 GB), which is not needed. So I want to untar backup.tar.gz to pipe excluding some files and tar it back without gzip. I have a text file, which contain names of dum…

How to reuse a function defined in another bash file?

I have a utility function that I used a lot (assertReturnStatus()). I’d like to define it in a utility file (utility.sh) and reuse it in other bash scripts. How can reuse the function from another bash script file? Thanks. Answer You need to “import” the first file in the second. Be warned t…

Bash script wait depended commands processes

I am fairly new in bash scripting. I need to use bash script for manage my microservices, so these services need build and deploy(on docker). So I have commands like that : So as you see(a little part of script, i am grouping depended commands in functions),commands need to wait previous depended commands lik…

Read line output in a shell script

I want to run a program (when executed it produces logdata) out of a shell script and write the output into a text file. I failed to do so :/ $prog is the executed prog -> socat /dev/ttyUSB0,b9600 STDOUT $log/$FILE is just path to a .txt file I had a Perl script to do this: I tried to do this

Use of $- in shell script

What is use of $- in Unix. In My system, the output is, what is meant by himBH? what it stands for. Thanks in Advance… Answer It returns the current shell’s flags. The $- variable contains the shell’s flags currently active in your terminal. These flags determine how your shell will function…