Skip to content
Advertisement

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

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

Advertisement