bash

bash alias not able to create

I tried to create an alias in bash but am not able to do. alias bundle-vendor= 'bundle install vendor --disable-shared-gems' ...

Bash script to append dynamic file path to existing .ini file possibly using sed?

Hello everyone, i have a commonly named .sqlite file contained within many unique user's home folders with file structure: /home/user/unique-ip-address/folder/file.sqlite I've decided to move all of these .sqlite files to a tmpfs mount and have already done so maintaining the full directory structure, so each .sqlite file is now in: /mnt...

mkdir error in bash script

Hi, The following is a fragment of a bash script that I'm running under cygwin on Windows: deployDir=/cygdrive/c/Temp/deploy timestamp=`date +%Y-%m-%d_%H:%M:%S` deployDir=${deployDir}/$timestamp if [ ! -d "$deployDir" ]; then echo "making dir $deployDir" mkdir -p $deployDir fi This produces output such as: making dir /cygd...

Test for a dot in bash

How can I test if some string is dot in bash? I've tried this: if [ "$var" = "." ] and this: if [ "$var" = "\." ] But it doesn't work. ...

BASH, multiple arrays and a loop.

At work, we have 7 or 8 hardrives we dispatch over the country, each have unique labels which are not sequential. Ideally drives are plugged in our desktop, then gets folders from the server that correspond to the drive name. Sometimes, only one hard drive gets plugged in sometimes multiples, possibly in the future more will be added....

How to download all your google docs from shell

Hello, gents. I learned how to download single google doc. But I am trying to make a script that downloads all my data in text format and then merges them in 1 text file. So, I wonder how to implement downloading part so that 1 can get zip file with all my files just as you do with web browser. Here is my newb script to get single file. ...

Linux: shell builtin string matching

I am trying to become more familiar with using the builtin string matching stuff available in shells in linux. I came across this guys posting, and he showed an example a="abc|def" echo ${a#*|} # will yield "def" echo ${a%|*} # will yield "abc" I tried it out and it does what its advertised to do, but I don't understand what the...

Bash script, read values from stdin pipe

I'm trying to get bash to process data from stdin that gets piped it, but no luck, what I mean is none of the following work: echo "hello world" | test=($(< /dev/stdin)); echo test=$test test= echo "hello world" | read test; echo test=$test test= echo "hello world" | test=`cat`; echo test=$test test= where I want the output to be ...

using bash: write bit representation of integer to file

Hullo First, I want to use bash for this and the script should run on as many systems as possible (I don't know if the target system will have python or whatever installed). Here's the problem: I have a file with binary data and I need to replace a few bytes in a certain position. I've come up with the following to direct bash to the o...

Linux/OpenSSL:Send find output to openssl

I am trying to send the output from the find command to OpenSSL in order to find out when certificates expire. This finds the files find . -name \*.pem -type f This generates the cert info I want openssl x509 -in certname.pem -noout -enddate Can I merge these two? Thanks for your help. ...

awk/sed/bash to merge/concatenate data

Trying to merge some data that I have. The input would look like so: foo bar foo baz boo abc def abc ghi And I would like the output to look like: foo bar baz boo abc def ghi I have some ideas using some arrays in a shell script, but I was looking for a more elegant or quicker solution. ...

Bash commands not executed when through cron job - PHP

Hi there! I have a cron job running a PHP script every five minutes; the PHP script executes two bash commands at the end of the script. I know the script is running due to a log file it appends to. When I run the PHP script manually via the Ubuntu Gnome Terminal both bash commands execute flawlessly; however when the PHP script is tr...

PHP & bash; Linux; Compile my own function

Hi. I would like to make my own program but I have no idea how.. for example I want to make a typical 'Hello $user' program. So.. ├── hi │   ├── hi.sh │   ├── hi_to.sh hi.sh #!/bin/bash ~/hi/hi_to.sh $1 hi_to.sh #!/usr/bin/php <?php echo "\nHellO ".$argv[1]."\n"; ?> Run it in terminal: me:~/hi → ./hi.sh User He...

Listing time every second as a Bash script

Hello all, first time here as I've finally started to learn programming. Anyway, I'm just trying to print the time in nanoseconds every second here, and I have this: #!/usr/bin/env bash while true; do date=(date +%N) ; echo $date ; sleep 1 ; done Now, that simply yields a string of date's, which isn't what I want. What is wrong? ...

How to store and echo multiple lines elegantly in bash?

I'm trying to capture a block of text into a variable, with newlines maintained, then echo it. However, the newlines don't seemed to be maintained when I am either capturing the text or displaying it. Any ideas regarding how I can accomplish this? Example: #!/bin/bash read -d '' my_var <<"BLOCK" this is a test BLOCK echo $my_var ...

symlink files newer than X age, then later remove symlink once file ages?

Hello everyone, i have a large number of files/folders coming in each day that are being sorted automatically to a wide variety of folders. I'm looking for a way to automatically find these files/folders and create symlinks to them all within an "incoming" folder. Searching for file age should be sufficient for finding the files, however...

How to make shell output redirect (>) write while script is still running?

I wrote a short script that never terminates. This script continuously generates output that I have to check on every now and then. I'm running it on a lab computer through SSH, and redirecting the output to a file in my public_html folder on that machine. python script.py > ~/public_html/results.txt However, the results don't show up...

How do I pass in the asterisk character '*' in bash as arguments to my C program?

Let's say I have a C program, and I run it from bash: $ ./a.out 123 * The program would output all the command line arguments, but it will show these instead: Argument 1: 123 Argument 2: a.out What can I do in my program to fix this? ...

Exit SSH from the script

I Want to exit ssh: How does the below line work: ssh -f -T ${USAGE_2_USER}@${USAGE_2_HOST} Or do i need to write it some other way . Please tell should I use exit with ssh an how? I am using ssh in my script . I want to exit from it after the execution of it, with out showing them up in the proccess. ...

bash/ksh/scripting eval subshell quotes

I'm using ksh and having some trouble. Why does this code not run? [root]$ CMD="ls -ltr" [root]$ eval "W=$( $CMD )" [root]$ ksh: ls -ltr: not found. [root]$ echo $W But this works fine: [root]$ CMD="ls -ltr" [root]$ eval 'W=$('$CMD')' [root]$ echo $W ...