Skip to content

Tag: bash

Bash export variables but only for current command

I want to load some environment variables from a file before running a node script, so that the script has access to them. However, I don’t want the environment variables to be set in my shell after the script is done executing. I can load the environment variables like this: However, after the command …

How to print IP address from Shell Script?

Below is my command line I want to get output of IP address(10.1.2.133) alone as output. How to write command line for that? Answer If you don’t mind a solution which is not elegant, but does the job, just pipe the output of your grep command into This splits the line first by the = and then :. If the

How to run a file in variable

I want to run this command: ././pscan `cat ips` 22 but the script don’t run corectly and i want to run command e.g: ././pscan 1.1 22 ././pscan 2.2 22 ././pscan 3.3 22 ././pscan 4.4 22 ././pscan 5.5 22 the script pscan works perfectly when i type on single command ././pscan 1.1 22 and i want to run more …

Read last line of file after the file was modified

I have a problem with reading the last line of file in Linux Ubuntu. I have a file named auth.log and I’m trying to read it last line after new line was added (after file was modified). I know i need to use tail -1 /var/log/auth.log to get last line but I don’t know how to check the file every