Skip to content

Running awk command in remote host fails

I am running a shell script to run awk command on a remote host. The awk command runs fine locally, but when run for the remote host fails (the redirected file is empty): Here is the script run on remote host: smb.conf.tmp is empty in remote host !! Locally: I followed this link for awk running on remote host…

Expanding shell variable in sed in remote host

The sed command, which is run locally looks like this (it works fine): However, if i try t run the same in a remote host doing an ssh, it gives me issue: What am i missing here? Answer Variable Expansion The problem you’re encountering has to do with shell expansion in strings. There are two relevant ca…

Extra backslash when storing grep in a value

In a bash script I have: When you run it it shows it as: Now it works exactly what I want but I want to understand it. Why is there 2 extra ‘s? Answer The output from set -x uses single quotes. So the outer double quotes were replaced with single quotes but you can’t escape single quotes inside a

auditing opened/closed ports on Linux

Is there an auditing tool to check which and when ports are opened and closed on Linux? My goal is to run my application and check its ports usage. lsof or netstat don’t fit because they just tell me which ports are currently opened, and looping on such command won’t give me accurate results&#8230…

Extract lines from File2 already found File1

Using linux commandline, i need to output the lines from text file2 that are already found in file1. File1: File2: Output: Thanks! Answer A more flexible tool to use would be awk Example What it does? NR==FNR{lines[$0]++; next} NR==FNR checks if the file number of records is equal to the overall number of rec…