Stray newline in file redirect

Bash
I have a batch script with the following two lines in it. svnversion . > myversion.txt set /p MyVersion=<myversion.txt This has always worked...
2 years ago

Convert decimal to hexadecimal in UNIX shell script

Bash
In a UNIX shell script, what can I use to convert decimal numbers into hexadecimal? I thought od would do the trick, but it's not realizing I'm feedi...
2 years ago

character case conversion Uppercase to Lower and vice versa

Bash
I was trying to convert the lowercase characters to uppercase. I came across various alternatives like one listing at the StackOverflow question. Howe...
2 years ago

How to count all the lines of code in a directory recursively?

Bash
We've got a PHP application and want to count all the lines of code under a specific directory and its subdirectories. We don't need to ignore commen...
2 years ago

Can one read input into a element of a associative array?

Bash
I want to use read to put data into a particular element of an associative array, so I wrote the following: typeset -Ag aa aa[key]='initial value' .....
2 years ago

Unix: removing duplicate lines without sorting

Bash
I have a utility script in Python: #!/usr/bin/env python import sys unique_lines = [] duplicate_lines = [] for line in sys.stdin: if line in unique...
2 years ago

How do I tell what type my shell is

Bash
How can I tell what type my shell is? ie, whether it's traditional sh, bash, ksh, csh, zsh etc. Note that checking $SHELL or $0 won't work because $...
2 years ago

Environment variable does not work inside command

Bash
I'm stuck for houres on this strange issue. I have a bashscript which is executing the following: TEST="12.x.x.x" echo ${TEST} gave me 12.x.x.x So...
2 years ago

Does bash have a way to un-export a variable without unsetting it?

Bash
Is it possible to export a variable in Bash, then later un-export it, without unsetting it entirely? I.e. have it still available to the current shell...
2 years ago

Expansion of variable inside single quotes in a command in bash shell script

Bash
I want to run a command from a bash shell script which has single quotes and some other commands inside the single quotes and a variable. e.g. repo f...
2 years ago

Strange Bash if/elif behavior

Bash
I have the following script: a=$1 b=$2 if [ ! a ]; then echo "a=$a" elif [ b ]; then echo "b=$b" fi This is the four possible ways I can c...
2 years ago

Example of xargs' -x option in action

Bash
GNU xargs has option '-x'. The man page says: -x Exit if the size (see the -s option) is exceeded. But xargs seems to not care if -x is set ...
2 years ago

Bash - how to exclude directory with find command and how to get full path with find?

Bash
so I have the code right now down below, and I'm running into a few problems with it I'm having trouble excluding the directories being outputted by...
2 years ago

Shell script to extract app name

Bash
I have Repo_URLs in Jenkins for various jobs which looks like: ssh://[email protected]:7999/sad/agreement-edge.git ssh://[email protected]
2 years ago

How to tar a directory from different - different server and copy to current server on which I am working

Bash
Actually I want to tar a directory from different-different server and need to move that tar to my current server on which I am working so I am writin...
2 years ago

Bash command to see if any files in dir - test if a directory is empty

Bash
I have the following bash script: if ls /Users/david/Desktop/empty > /dev/null then echo 'yes -- files' else echo 'no -- files' fi How w...
2 years ago

How to use variable in sed search pattern

Bash
I will show an example to explain my problem. VARIABLE='some string' I want to search the string in file like: sed -n "/$VARIABLE,test/p" aFile ...
2 years ago

How to output the sips image in directory

Bash
sips --resampleWidth 300 --out ./changedPic/A.png ./Normal/A.png I did this command in shell. however it didn't make the A.png under changedPic di...
2 years ago

Shell equivalent to "try/except" in Python?

Bash
I'm cleaning the output of my scripts. For example: rm -f ./file No such file or directory So, I need something like the try/except in python....
2 years ago

Subtract 2 variables in Bash

Bash
I have the script below to subtract the counts of files between 2 directories but the COUNT= expression does not work, what is the correct syntax? #!...
2 years ago