Terminal command to get JUST IP address and nothing else

Bash
Is there an easy way in a unix terminal to get JUST the IP address, rather than looking through ifconfig? I'm trying to use it as a parameter in a scr...
1 year ago

Confused with shell script reading CSV data from file

Bash
I'm fairly new to Linux/CentOS and shell scripting. Let's say I have a file named useraccounts.list. This file contains CSV data in this specific orde...
1 year ago

Check if i use sudo or su

Bash
I want a script shell make the user use su not sudo I want a script check if i use sudo or su in my command, like : if [ "$USER" != "root" -a "$0" ...
1 year ago

Bash: Copy named files recursively, preserving folder structure

Bash
I was hoping: cp -R src/prog.js images/icon.jpg /tmp/package would yield a symmetrical structure in the destination dir: /tmp | +-- package | ...
1 year ago

Bash: duplicate + rename folder

Bash
Suppose I have a folder named my_folder_old in /path/to/folder, how can I create a duplicate named my_folder_new in the same directory? EDIT Moreove...
1 year ago

linux kill process using timeout in milliseconds

Bash
I want to force terminate a program after a specified time is elapsed on linux. I found that 'timeout' util in linux can kill a program after a specif...
1 year ago

how to use variables with brace expansion

Bash
I have four files: 1.txt 2.txt 3.txt 4.txt in linux shell, I could use : ls {1..4}.txt to list all the four files but if I set two variables : ...
1 year ago

Docker bash prompt not display color

Bash
I use command: docker run --rm -it govim bash -l to run docker images but it cannot display bash prompt color. If I source ~/.bash_profile or run bas...
1 year ago

How to record terminal execute log?

Bash
I want to record bash execute history in a log, including input and output, and timestamp. The command history only can record input, but not output a...
1 year ago

shell script to check wether a server is reachable?

Bash
I have 5 Solaris servers present across different locations . sometimes some of these servers are not reachable due to various reasons (network probl...
1 year ago

In shell script will sync cmd wait until first cmd is executed completely

Bash
In shell script will second cmd wait until first cmd is executed completely ie in case of sync folders ? eg : cmd1 sync folder1 cmd2 cp folder1 to...
1 year ago

List file names based on a filename pattern and file content - GREP?

Bash
How can I use Grep command to search file name based on a wild card "LMN2011*" listing all files with this as beginning? I want to add another check...
1 year ago

How to load ~/.bash_profile when entering bash from within zsh?

Bash
I've used bash for two years, and just tried to switch to zsh shell on my OS X via homebrew. And I set my default (login) shell to zsh, and I confirme...
1 year ago

Make sure int variable is 2 digits long, else add 0 in front to make it 2 digits long

Bash
How do I check a int variable ($inputNo) to see if it’s 2 or more decimal digits long? Example: inputNo="5" Should be changed to: 05 inputNo="102...
1 year ago

how to find variable is empty or "" in shell script

Bash
How can I check if a variable is empty in Shell?
1 year ago

Filter non-alphabetic characters out of string in shell script

Bash
Very simple question but can't seem to find a simple answer... I am writing a bash script which needs to remove all non-alphabetic and non-numeric ch...
1 year ago

Comparing files, but ignoring specific differences, in a shell script

Bash
I have a shell script that compares files of the same name across two directories and alerts me to differences. Most of the time the files files in a...
1 year ago

How to do a loop with filenames in shellscript ordered by 'last modified'?

Bash
i'm new in Linux, and i've been trying to run a script which processes all the files in a folder using ImageMagick's convert (I rather do this task in...
1 year ago

Concatenate and remove carriage return in Shell Script

Bash
In shell script I am doing the following: locationUrl=$(grep -r "Location:" output.txt) fullUrl="http://test.com/temp/${locationUrl##*/}" tempUrl="$f...
1 year ago

Shell script printing contents of variable containing output of a command removes newline characters

Bash
I'm writing a shell script which will store the output of a command in a variable, process the output, and later echo the results. Here's what I've go...
1 year ago