I want to make shell script file in windows and linux with multiple commands inside it. E.g run.sh and run.bat with the below commands run.bat or run.sh When I run my run.bat file it only executes first command mvn clean but it do not execute other commands. How to make shell-script file with multiple command…
Tag: bash
possible to script to open multiple terminals in local machine and ssh to different servers?
This is what I’d like to do: On my local linux system (Ubuntu), I’d like to write a script which would open multiple terminals, and do an ssh to different servers (the list of servers would be in a text file which the script will read), and execute a program on each of those servers. Is this possi…
In bash got unwanted newlines after sed and cat >>
I’m trying to substitute some lines in /etc/hosts file with my script here: It searches e.g. for lines like and replaces the line (if it’s found) with a sed command to nothing, but adds afterwards e.g. to I’m having to do (?) this because my LAN network addresses are changing very often (exa…
Bash – delete rows from one file while iterating through rows from another file
I have two files. file.txt and delete.txt file.txt contains the following for ex.: delete.txt contains: I need to delete the rows from file.txt that are contained within delete.txt cat file.txt should result with: So far I’ve tried this with no luck: I don’t receive any error, it just doesn’…
optimize xargs argument enumeration
Can this usage of xargs argument enumaration be optimized better? The aim is to inject single argument in the middle of the actual command. I do: or I get: which is what I need but I wondered if loop and temporary variable could be avoided? Answer Try without xargs. For most situations xargs is overkill. Depe…
Bash Scripting: How to display output for the passwords expiry every 2 week
My question is, how do i edit the script such that if PASS_MAX_DAYS is equals to 14 days or less then it equals to “Vulnerability: No”? Output My Script Answer You can use grep -oP “^PASS_MAX_DAYSs+K([0-9]+)” /etc/login.defs to extract the value : K starts the match from the position o…
Bash Scripting: How to display output for checking root logins via SSH not allowed?
My question is, how do i make the script into a if else statement that it checks if “PermitRootLogin no”, it should display the “Vulnerability: No” and if the “PermitRootLogin yes” it should display as “Vulnerability: Yes”? Thanks in advance! Output Script Answe…
Delete all files except a few using bash command
I have a directory containing lot of files in different formats. I would like to know how I can delete all files with specific format (Lets say *.dat) except a few files in a same format (e.g. A.dat and B.dat). Please advise! Answer I’d write a little script (as a command-line one-liner it is slightly t…
Validate text file presents expected fields for each data set
If one has a document in this format: You could verify each field exists for each data point manually by scrolling through thousands of lines in a file, but that would be inefficient and time consuming. I have thought about splitting the file and comparing each section using diff, but again, that would be pro…
shell script mv is throwing unhelpful error “No such file or directory” even though i see it
I need to use a shell script to move all files in a directory into another directory. I manually did this without a problem and now scripting it is giving me an error on the mv command. Inside the directory I want to move files out of are 2 directories, php and php.tmp. The error I get is cd: /path/to/working…