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
Tag: shell
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’
Vim use different config or shell enviroment variable when spawning new terminal
Ok, so lets say I spawned a new terminal in vim using :terminal and I want to immediately have a shell enviroment with different/additional enviroment variables within that new terminal window without typing for example VAR=”something”. How do i do that? Answer You can set an environment variable in vim and then open a terminal, which will inherit all environment
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
How to remove the lines which appear on file 1 from another file 2 KEEPING empty lines?
I know that in other questions you solve the first part of “How to remove the lines which appear on file 1 from another file 2” with: comm -23 file1 file2 and grep -Fvxf file1 file2 But in my case I have empty lines separating data sets that I need to keep, for example: File 1: File 2 what I
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
In Linux Shell, how to find out which commands I use most often and how often?
I want to find out which are the top 5 commands that I ran in the shell. I want to see which commands I use most often. It would be great if I can also see how often I ran these top commands. Is there an easy way to find it without installing any plugins? Answer You can do 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