How regular expression assertions can be written in shell script in ubuntu

Bash
The following is a valid regex in many languages, but it doesn't work in bash: ((?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[@#$%]).{6,20}) How can I write ...
1 year ago

xterm doesn't run shell script

Bash
so I'm trying to use this command: export DISPLAY=:1; /usr/bin/xterm -hold -e /path/to/shscript Where shscript is: #!/bin/bash echo "Restarting .....
1 year ago

Compare two strings in shell, one coming from a command return

Bash
I'd like to compare two strings to know if my Bluetooth is on or off using blueutil I tried this : cd ../../../usr/local/bin ./blueutil status a=$(....
1 year ago

OS X Automator and shell issue

Bash
I'm trying to make an automator workflow on OS X which opens the selected images in the finder and opens it with Photoshop During this, I need to use...
1 year ago

Access a variable referred back twice UNIX

Bash
This is a simple question, but I have the variables classNext1="Exists!" classNext2="Exists!" classNext3="Does not exist yet!" classNext4="Does not e...
1 year ago

What is the proper way to test if variable is empty in a batch file, If NOT "%1" == "" GOTO SomeLabel, fails if %1 has quotes

Bash
I need to test if a variable is set or not. I've tried several techniques but they seem to fail whenever %1 is surrounded by quotes such as the case ...
1 year ago

psql displaying ansi colored text

Bash
My .psqlrc has following options \setenv LESS '-iMSx4 -FXR' \setenv PAGER 'less' \pset pager always and psql output which I want to be colored is ...
1 year ago

Split string into array Shellscript

Bash
How can I split a string into array in shell script? I tried with IFS='delimiter' and it works with loops (for, while) but I need an array from that ...
1 year ago

How do I programmatically input after a prompt with bash script?

Bash
I have to run a bash script bash.sh that starts up a command line tool. That command line tool has a prompt that says Please enter your email: I th...
1 year ago

Bash script to get into a running container and then run another bash script from that container

Bash
I have a shell script which runs as follows : image_id=$(docker ps -a | grep postgres | awk -F' ' '{print $1}') full_id=$(docker ps -a --no-trunc -q...
1 year ago

Automatically chdir to vagrant directory upon "vagrant ssh"

Bash
So, I've got a bunch of vagrant VMs running some flavor of Linux (centos, ubuntu, whatever). I would like to automatically ensure that a "vagrant ssh"...
1 year ago

How to execute multiple command after double pipes in shell script

Bash
I am writing a Korn shell script where I have a function like this #!/bin/ksh myfunc() { some_command1 || return 1 some_command2 || return 1 ...
1 year ago

Which characters need to be escaped in Bash? How do we know it?

Bash
Is there any comprehensive list of characters that need to be escaped in Bash? Can it be checked just with sed? In particular, I was checking whether...
1 year ago

Error using arrays in shell script

Bash
I was testing a shell script in which arrays were used. This is an example taken from tutorialspoint #!/bin/sh NAME[0]="Zara" NAME[1]="Qadir" NAME[2...
1 year ago

timestamp=$(date +%Y%m%d) not evaluated in shell script

Bash
I have a shell script that calls another shell script. One of the parameters is the output filename which I want to prefix with a timestamp. So far I'...
1 year ago

"ls: not found" after running "read PATH"

Bash
I'm trying to write a little script to list a directory from a given variable. However, I can't run ls at all after reading my input into the variabl...
1 year ago

List all files older than x days only in current directory

Bash
I am new to unix and couldn't get appropriate outcome in other questions. I want to list only files in current directory which are older than x days....
1 year ago

How to tell if a string is not defined in a bash shell script?

Bash
If I want to check for the null string I would do [ -z $mystr ] but what if I want to check whether the variable has been defined at all? Or is th...
1 year ago

in unix, how could i count lines of code not starting with white spec

Bash
test1: 1. samplinggggggg 2. samplinggggggg 3. samplinggggggg test2: 1. samplinggggggg 2. samplinggggggg 3. samplinggggggg 4. samplingggg...
1 year ago

Uninstall system app programmatically from rooted Android phone

Bash
I am building an app for some set of rooted phones I have. I was wondering if there is any way that I could uninstall a system app which comes with th...
1 year ago