sh

How to append lots of variables to one variable with a simple command

半世苍凉 提交于 2019-12-06 04:42:12
I want to stick all the variables into one variable A=('blah') AA=('blah2') AAA=('blah3') AAB=('blah4') AAC=('blah5') #^^lets pretend theres 100 more of these ^^ #Variable composition #after AAA, is AAB then AAC then AAD etc etc, does that 100 times I want them all placed into this MASTER variable #MASTER=${A}${AA}${AAA} (<-- insert AAB, AAC and 100 more variables here) I obviously don't want to type 100 variables in this expression because there's probably an easier way to do this. Plus I'm gonna be doing more of these therefore I need it automated. I'm relatively new to sed, awk, is there a

How can I get FFmpeg to locate installed libraries when --sysroot is pointing to another directory?

喜夏-厌秋 提交于 2019-12-06 04:18:32
问题 I've been going at this, literally for days. I'm trying to build FFmpeg with libmp3lame for use in an Android application. The build script sets a --sysroot flag that points to the Android NDK directory necessary to build these libraries in a way that Android can use them. The problem comes when I add the flag to --enable-libmp3lame ; I get ERROR: libmp3lame >= 3.98.3 not found during the build start up. I know that LAME, and it's libraries are installed, because I can just run ./configure -

xcodebuild fails to build from terminal but succeeded from xcode

不问归期 提交于 2019-12-06 03:26:24
问题 I'm trying to build a framework using xcode 6-beta 3 when compiling it using xcode it works but when compiling it from a terminal with the command: xcodebuild -project <projName> -scheme <schemeName> -configuration Debug clean build I'm getting the following error CodeSign error: entitlements are required for product type 'Framework' in SDK 'Simulator - iOS 8.0'. Your Xcode installation may be damaged. and the build fails to complete. at the end of the log it says The following build commands

What do I need to quote in sed command lines?

给你一囗甜甜゛ 提交于 2019-12-06 03:16:16
There are many questions on this site on how to escape various elements for sed, but I'm looking for a more general answer. I understand that I might want to escape some characters to avoid shell expansion: Bash : Single quoted [strings] ('') are used to preserve the literal value of each character enclosed within the quotes. [However,] a single quote may not occur between single quotes, even when preceded by a backslash. The backslash retains its meaning [in double quoted strings ] only when followed by dollar , backtick , double quote , backslash or newline . Within double quotes, the

get variables substituted when I cat a file

吃可爱长大的小学妹 提交于 2019-12-06 02:33:22
Is it possible, in a clean way to get the variable values when I cat a file, instead of the variable names, as written in the file. It's hard to explain, but here goes a simple example: $ cat <<EOF $HOME EOF /home/myself cat returns /home/myself because it is already expanded by the shell. $ echo \$HOME >/tmp/home $ cat /tmp/home $HOME cat simply reads the file, I want $HOME to be expanded here somehow by cat, because the file will contain variable names (not like HOME=/home/myself) My question is if this is possible somehow, otherwise I will have to write some dirty code. EDIT: they are big

In a bash script, what would $'\0' evaluate to and why?

送分小仙女□ 提交于 2019-12-06 01:16:17
问题 In various bash scripts I have come across the following: $'\0' An example with some context: while read -r -d $'\0' line; do echo "${line}" done <<< "${some_variable}" What does $'\0' return as its value? Or, stated slightly differently, what does $'\0' evaluate to and why? It is possible that this has been answered elsewhere. I did search prior to posting but the limited number of characters or meaningful words in dollar-quote-slash-zero-quote makes it very hard to get results from

Bash bug re $LINENO— or am I just confused?

旧街凉风 提交于 2019-12-05 23:36:08
问题 Consider: #!/bin/bash echo ' ' $LINENO echo '' ' ' $LINENO The first echo correctly prints a 4, but the second echo prints a 5 instead of 6. Am I missing something, or is this a bug? (Using bash 3.00.15) 回答1: It looks like an implementation misfeature (bug) in bash. I used: #!/bin/bash -p echo $LINENO echo ' ' $LINENO ' ' $LINENO ' ' $LINENO echo '' ' ' $LINENO which yielded: 2 3 3 3 6 Which supports the theory that the variable is evaluated before the shell considers the line to have been

Is there a `ssh-add` Linux alpine one liner

杀马特。学长 韩版系。学妹 提交于 2019-12-05 20:07:03
问题 I need during a Gitlab-CI build to authenticate with ssh-agent from an alpine image. I am looking for a sh one liner equivalent of this bash command (picked from the gitlab documentation): ssh-add <(echo "$SSH_PRIVATE_KEY") I have tried : echo $SSH_PRIVATE_KEY | ssh-add - Enter passphrase for (stdin): ERROR: Job failed: exit code 1 printf '%s\n' "$SSH_PRIVATE_KEY" | ssh-add ERROR: Job failed: exit code 1 回答1: You have to quote the variable in your first command: echo "$SSH_PRIVATE_KEY" | ssh

Executing .sh scripts via PHP

怎甘沉沦 提交于 2019-12-05 17:09:38
I have a few game servers that that I need to run shell scripts for frequality. I'm trying to figure out how to run these scripts via a webpage on the same server. It's a Ubuntu Dedicated server. The website files are located via /var/www/... The .sh files I need to manually run are located in /home/amservers/.../start.sh . I've looked at other answers and I still can't figure it out. How do locate the files and store it and then run exec()? You could just use the shell_exec() function in PHP: http://php.net/manual/en/function.shell-exec.php shell_exec('sh script.sh'); And if you want to use

Git 'pre-receive' hook and 'git-clang-format' script to reliably reject pushes that violate code style conventions

可紊 提交于 2019-12-05 16:14:45
问题 Let's immediately start with a scrap of the pre-receive hook that I've already written: #!/bin/sh ## format_bold='\033[1m' format_red='\033[31m' format_yellow='\033[33m' format_normal='\033[0m' ## format_error="${format_bold}${format_red}%s${format_normal}" format_warning="${format_bold}${format_yellow}%s${format_normal}" ## stdout() { format="${1}" shift printf "${format}" "${@}" } ## stderr() { stdout "${@}" 1>&2 } ## output() { format="${1}" shift stdout "${format}\n" "${@}" } ## error() {