Skip to content
Advertisement

Tag: shell

Linux shell temporary DNS

In a linux shell script, I want to change the dns address temporarily. To do this, I can insert temprary dns address into resolv.conf right after the shell run and remove it before the script ends. That’s it. But the problem is, all every other scripts also hit the address while the script is running. This is not what I

which is better? using cd and execute or using absolute path?

Suppose I would like to do some operation like touch/rmetc on a specific directory in shell script. Firstly, I can do cd to that directory and do it. Secondly, I can use absolute path to do that. My question is which one will be better in performance perspective? Which one is faster? Answer You can time it yourself: with this

Linux shell: my `expect` script doesn’t work as expected

I’ve got a simple script like below, read 2 numbers from command line and add them together: It runs, no problem. Then I wrote an expect script like below: Seems still it prompts to read from command line, after quite a long time, it ends. Where did I get wrong? Thanks. Answer You have to send the newlines as well,

linux bash script log output

Im having trouble getting output into my log file in my script. Backup runs successfully but the logfile is empty. WHen I run the script I get “Warning: Using a password on the command line interface can be insecure.” so at least that should be in a log file. (I am using a .key file) Answer Thats because, only error

Sort on specific part of filename in shell script

I have a list of files which I want to delete except 2 of the most recent ones. The files are named as “filename_dd_mm” for example “filename_19_05”. If I do It sorts them according to the day. What I want is to sort them by month first and then the day. Can someone please guide me to do this. P.S.

How to take input in beginning of the program?

I am making a program which needs the user input in the beginning of the program if you don’t get my question i will give you an example: So, I want the input in the beginning of the program. I think the input will be stored in a variable. If yes, Then please tell me in which variable it is

Advertisement