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…
Tag: linux
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
Why linux split program have weird behavior with large files >20GB?
I’m doing the next statement on my ubuntu: If i do a “ls” If i do a “du” over ab and ad files. As you can see, split divided the file in a non-homogeneous form. Anyone know what’s going on? Some unprintable character can hang the split? Thank you. Best Regards! Francisco. A…
shell script to kill tomcat service if it is not stopped by stop command after certain amount of time?
I would like to write shell script to start and stop tomcat server.For stopping the tomcat I am using this command “./bin/shudown.sh” or “./bin/catalina.sh stop”. This is not working most of the times, tomcat is still running.So I would like to kill the tomcat after giving shutdown com…
How to append entry the end of a multi-line entry using any of stream editors like sed or awk
I am trying to use a script to append the host name at the end of a multi-line entry of a specific Host_Alias field in sudoers file. The current sudoers file has an entry similar to : My required output would be something like the following where I have added “,host25” There are more lines before …
django settings.py os.environ.get(“X”) not fetching correct values
I am trying to access and fetch (get) value of OS Environment variable into settings.py and while debugging application I get None value for that record. Here are more details: There are some important/secret keys which can’t be shared in code so those are exported in OS environment variables. Whenever …
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……
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…
How to handle missing values while calculating average in shell script?
I have a dataset with many missing values as double slash (//). Part of the data is I would like calculate the average in each 6 rows interval without considering the missing values. I was trying with this, but not getting what I need. It is giving But the answer should come Answer You need to modify the awk …
cx_Oracle does not recognize location of Oracle software installation for installation on Linux
I have been able to successfully install cx_Oracle for use with Python 3.4 on my Windows 8 laptop, and I am now trying to get the same setup (cx_Oracle with Python 3.4) onto a Linux machine. When running the setup.py file from cx_Oracle-5.1.3.tar.gz, I end up with this error: Following some other answers I lo…