Skip to content
Advertisement

Tag: shell

Wrapper script that write logs of arguments, stdin and stdout

I want to create a wrapper script which writes logs of arguments, stdin and stdout. I have written the following script wrapper.sh, which works almost fine. I expect that ./wrapper.sh arg1 arg2 gives the same result as /path/to/command arg1 arg2 with logs in /tmp/stdio-log/. But it gives a slightly different result in Example 2 below. Example 1: a command that

Shell Script – Print directories/files & file numbers

I’m trying to write a shell which can print the directories & files in it. I want to add number (for loop) to files in it, but having issues – can you experts look into it and help me out? Thanks Answer Solved – Updated while loop with following – was simple than anticipated ๐Ÿ™‚

How to zip multiple folders separately in linux

Below mentioned folders contain some data. I need to zip all the folders separately. With this Command, I can zip only one folder How can I zip all the folders separately at once? Answer First, make sure that you are in the directory where the above mentioned folders are. Then run: find . -type d -maxdepth 1 -execdir zip ‘{}.zip’

Why cant I get mv to rename and copy file?

The last thing I want to do in this script is take the userinput to rename the corresponding files to include .bak extension rather then .txt which will copy into a backup directory. I keep receiving an error messaging saying e.g. The snippet in question (right at the bottom of full code): Full code: Answer The correct one would be

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

Why copy command is not working when using file paths?

I’m having a problem with the copy command. cp ../teste/env/test/x.tar ../../../teste2/file The folders exist and also the file x.tar. When I start the script I’m on a different folder, so that’s why I make a ../ at the begining. It keeps giving me this error: cp: cannot create regular file โ€˜../../../teste2/fileโ€™: No such file or directory Worth to note that

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