I’m trying to troubleshoot issues I’m having with an Amazon CLI backup script that’s running on Ubuntu Server 16.04. When I run the script manually I see that my if statements throw errors. Per request I’ve reduced my example to be minimal and verifiable. This script was running on another production server just fine. I’ve also run it through a
Tag: shell
Ubuntu bash script grepping and cutting on first column
I am trying to implement a bash script that will take the piped input and cut the first column and return a total. The difference is that the cut is not from a file, but from the piped input. For example: Basically, in my scenario the first column will always be from the passed input. Example usuage is: data.txt contains:
Shell script to list unformatted disks (partitions)
I’m looking to create a script that lists the unformatted partitions/disks in Linux OS. I couldn’t find a reliable way of listing the unformatted disks / partitions. I tried to use lsblk –output NAME,FSTYPE,MOUNTPOINT | grep “sd” which outputted: The names which do not have mountpoint listed against them are unformatted disks. How can I get those names? Or what
How to insert variable containing a path into sed
I’m writing a linux script, which is to replace a string for a file. Here is my script: In the file named test, there is a line like this: What I need is to replace this line with the line below: It means that things between double quotes should be replaced by the $var. However when I execute my script,
How to save changes from two variables?
I need to write a bash script, which checks if a new user logged in within 5 seconds, and if so, print it’s details: name, username, …… I already have the following code, which checks if a new user have logged in: Answer If I understand the question correctly, you want to find the difference between two Bash variables and
Print only a part of the result of a command
I am trying to obtain the status of a httpd service with Centos 7. I want to know if i can print only the value of Active, that in this example is inactive (dead) This is the command that i am using: This is the result of that command. This is the output that i a want: inactive (dead). Answer
Convert multiple SFTP command lines to a single line command line
How do I convert this EOF into a one line sftp command-line? Answer Your question has nothing to do with SFTP/sftp. It’s just a generic shell question. So use any method that a shell allows, for example
Linux Bash find files on user input with multiple -name clauses
I am trying to create small utility to collect log files from remote host by creating tar ball, for simplicity assume for now assume to just display list of files based on user input. This command works fine If i programmatically want to update -name clause based on the user input, say for example user input is process3.log*, process4.log*, process5*.log
How to have shell script available to run in terminal and searchable in /bin?
I downloaded CLion from Jetbrains, and it is a .tar.gz with a shell script to run it. I decided to put it in my /opt folder, but now I can’t figure out how to run it from anywhere, and have it available in /bin (for programs like dmenu that search /bin for executables). I tried adding the path to the
How to get logs of individual argument passed to shell script from a file
I have a shell script. In this script I am reading table names for a file and executing a command. The script is working fine. I am able execute the command for all the tables in the file. shell script In this script I want to collect status logs and stdout logs. I want to collect the logs for each