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
Tag: bash
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 …
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…
Bash script to execute commands on system boot up
I am trying to make a bash script to check for two data values and weather or not they are set to 1 or 0 I want to do something. These values usually are set on system bootup and are defined usually after system is completely up (that is why I am using a while loop to keep checking until
Use Xargs to wait for enter key
So, I have a list of files that I want to use to generate a new set of groups of files. I want to open up these groups (multiple files) together at once. Edit them. Then go back to the terminal, hit enter, and open up the next group of files. I’ve got it working, but I’m using a temporary
The Majority of Unix tools are written in what programming language? [closed]
Closed. This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 7 years ago. Improve this question Here is an example of using two Unix tools: ls and grep are two Unix tools…
Jenkins adding single quotes to bash shell script
My shell script looks like this: It’s checked into cvs in a shell folder, Jenkins is configured to execute it on a Linux machine via a job with ‘Execute Shell’ build step: But Jenkins is wrapping the whole sudo line in single quotes which results in my log files not been deleted (although th…
deletion of file after 7 days
I have to delete multiple files after 7 days regularly. And the deletion dates and location are different for each file.Yes, I can apply a cronjob for each folder separately but tat will involve many cronjobs (atleast 15). In order to avoid this, I want to create a script which will go to each folder and dele…
Difference on bash and ash parentheses
I was trying to use a diff command for comparing directory listings which works fine in bash: However, on the ash (embedded device where no other shell is available) I get Is there any difference regarding reading input operator < or parentheses ( )? Answer Don’t confuse the angle bracket in <( … …