Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [syntax]

The tag has no usage guidance.

0
votes
0answers
26 views

Resource Request! Clear and simple explanation of the syntax and situational use of special characters for Bash scripting [on hold]

When using Bash and the common tools grep, tee, sed, awk and the other common Bash-scripting utilities, I find myself getting confused on the use of special characters such as / \ ' " : ; $ and the ...
0
votes
2answers
66 views

syntax error near unexpected token 'elif'

I get the error on the 7th line. Any ideas? I checked for spaces and there are none. #!/bin/bash if test $# -eq 0 then echo "No arguments" elif test $# -eq 1 echo "$1" elif test $# -eq 2 ...
0
votes
2answers
74 views

Changes to bash shell script language? [closed]

i wrote a multipart script that calls rsync a few years ago and it has always worked. After a year of no use and alot of debian apt-get updates, now the script stopped working. Main2Network1.sh ...
0
votes
1answer
66 views

Why would calling cd (builtin) from cd (shell function) without “command” cause an endless loop?

I once read in a Bash book by O'Reilly the following (my summary): command and enable cd () { echo "Improved CD !" # Improvement one; command cd # Improvement two; # Do cool ...
2
votes
0answers
26 views

How to maintain a list of names for the Hunspell spell checker?

Hunspell should help the user to write names properly. The names should be defined in the home directory of the user, so that every user can define his or her own list of important names. If a user ...
0
votes
1answer
161 views

How to run Ansible playbooks only if there are no problems in the playbook?

I have learned of the command ansible-playbook example.yml --check which can tell me if something in my playbook is problematic (as far as Ansible can recognize). I think I should combine this ...
0
votes
1answer
20 views

What are the basic files (dirs and regular file) in Ansible-Galaxy roles? [closed]

I have an Ansible playbook for establishing LAMP environments on remote machines. Part of this playbook deals with installing Composer: - name: Install Composer get_url: url: https://...
2
votes
1answer
74 views

Is it a best practice to use Ansible-Galaxy roles in playbooks instead ansible-modules in playbooks? [closed]

I have an Ansible playbook for establishing LAMP environments on remote machines. Part of this playbook deals with installing Composer: - name: Install Composer get_url: url: https://...
2
votes
2answers
260 views

How to write regexp literal in match expression?

This question is about the proper way to write regular expression literals in a match expression under bash. In zsh, the match below succeeds, as I expected: % [[ ' 123 ' =~ '^ [0-9]+ $' ]]; echo $? ...
1
vote
0answers
30 views

Sed command writes the expression in outer ifmodule

my config file has this <IfModule mod_dir.c> DirectoryIndex index.html index.cgi index.pl index.php index.xhtml index.htm </IfModule> I want to change "index.php" to "index.temp" I ...
-9
votes
5answers
907 views

What is masking a mode? [closed]

I understand that in GNU/Linux, file permissions are also called a file's mode and that the term "umask" can mean at least these different meanings: The umask shell builtin command (the usual meaning)...
3
votes
1answer
62 views

Have remind send out notifications some days in advance

I have been trying to use the Unix program remind, and so far I enjoy the flexibility. I have set up this command to warn me of any upcoming reminders: ~$ remind -z -k'notify-send "Reminder" "%s"' ....
2
votes
2answers
122 views

How can I use “source-highlight” with “git show”?

Using source-highlight in conjunction with less works really well, but I'm struggling to see how I can use it with git show because there's no file extension to clue source-highlight about the ...
3
votes
1answer
66 views

Using a bash array in an awk and also quoted variable: conflicting syntax issue

I have a script the aim of which is: For a list of files, obtain a specific number for each file (this is sequencing data, to be specific) and store these into array1 Using array1, find the smallest ...
15
votes
1answer
1k views

Bash script function names containing double colon '::'

I came across a Bash script today that has function names with double colons :: in them, e.g., file::write() and file::read(). I've never seen this syntax before in a Bash script, and when I invoked ...
1
vote
1answer
77 views

Dash Slash Meaning vs just Slash -/var vs /var [duplicate]

Working with Centos 7 In the rsyslog.conf file there are some rules that place logs in directories that start with a -/ (Dash slash) before stating which directory to place the logs, while others ...
6
votes
4answers
1k views

back ticks vs double quotes

I've been wondering this for a long time but haven't figured out how to look it up - is this: x=`command -v r2g` the same as this: x="$(command -v r2g)" or is it the same as this: x=$(command -...
0
votes
0answers
21 views

Command to launch a file who's name changes from time to time,

I have an automator workflow set to perform a certain set of functions that ultimately caps in launching an application. For now the program works just fine but the version of the application is kept ...
48
votes
3answers
7k views

Is $() a subshell?

I understand the subshell syntax to be (<commands...>), is $() just a subshell that you can retrieve variable values from? Note: This applies to bash 4.4 based on different wording in their ...
2
votes
0answers
64 views

What are the contexts where Bash doesn't perform word splitting and globbing?

Bash doesn't perform word splitting in globbing in these cases: LHS or RHS of an assignment, except for indexed arrays var=$value # simple variable declare -A hash key=...
-1
votes
2answers
205 views

Why not seeing shell globs as a “dialect” of regex? [duplicate]

I often confuse Bash 3.x shell globs: ? # Match any single character. * # Match any string of characters (up until the asterisk). [set] # Match any character in set (but not the entire set ...
0
votes
1answer
18 views

lp -d lp1 -h myfile has two options and one argument or 2 options and 2 arguments?

In "Learning the Bash Shell" by O'reilly (third edition), it is written in page 7: lp -d lp1 -h myfile has two options and one argument. How come? I see what I reckon as two options, each one with ...
0
votes
1answer
175 views

What does the asterisk (*) mean in lsof output?

I set my TCP server to localhost 127.0.0.1, but instead of seeing 127.0.0.1 in the host portion of the lsof output, I see an asterisk. After running lsof -i... my_process 66666 root 5u IPv4 0xffff......
-1
votes
5answers
243 views

Are if-fi segments necessary when iterating on a pushd-popd directory list?

I use the following code which is part of this script that I use to update my WordPress websites: #!/bin/bash drt="/var/www/html" for dir in ${drt}/*/; do if pushd "$dir"; then wp plugin ...
1
vote
2answers
188 views

AWK usage for simulatenous inline division and taking absolute value

I have a data file of this format (top row is for reference): E T N D S s R k 0.45847 300.0000 9....
1
vote
1answer
120 views

Hyphen (-) ignored in the end of a piped command nested inside a function?

I use Ubuntu 16.04 (xenial) with Bash 4.3.48(1). Based on the answer of Stephen Kitt in this session, I tried run the following command as part of a function named imb(): mysqldump -u root -p --all-...
0
votes
1answer
471 views

-e option in command grep

I encountered a problem when reading grep manual refering to it -e option, It say: -e pattern, --regexp=pattern Specify a pattern used during the search of the input: an input line ...
1
vote
1answer
79 views

Concerning AWK programming, what do the -f switch and ~ operator do? [closed]

I've been looking into this for a project, beginner stuff, and I can't seem to find anything on these switches. I know the "-F" option can be used to change the delimiter but that's the extent of what ...
1
vote
1answer
55 views

How to Define Custom Conditional Expression Primaries in Bash?

How would I redefine and/or define new conditional expression primaries in bash? For example, I would like a primary that tests for the existence of an empty directory. Of course, it would be ...
0
votes
1answer
1k views

Rsync include from and exclude from a list

I am trying to use rsync include-from and exclude-from commands to ignore or only copy listed files/directories from a source. The list is in a text file. For some reason the command does not execute. ...
0
votes
1answer
505 views

How does pushd work?

In Ubuntu 16.04 with Bash I had a problem when I didn't have a convenient way to upgrade all my WordPress components (core, translations, theme, plugin) and I used the following code to solve it: cat ...
0
votes
1answer
238 views

List of acceptable initial characters for a bash variable

What are the acceptable characters in a bash variable? Can someone point me to the place in the bash man page that describes the acceptable name for a bash variable? I looked and came up with a lot ...
0
votes
1answer
523 views

Concatenating a list of files using For loop

I'm new to unix/bash/code in general, and I'm trying to merge multiple sample files with the same name in different directories into a new file in its own directory (the outputs of multiple data ...
0
votes
1answer
2k views

shell script error : Syntax error: “(” unexpected

I have checked the previous post on this error. still did not get the solution working. Here is my bash script. can some one help me figure out the issue . I have used https://www.shellcheck.net/ to ...
2
votes
2answers
1k views

Syntax error near unexpected token 'else'

I'm trying to create a script that will remove certain parts of a txt file full of status info and other various text. I can't end the main if statement. Also I'm trying to get it to delete the ...
2
votes
0answers
33 views

Exclude subdirectory from zip archive — explain syntax please

I want to zip a folder recursively, but exclude certain directories (temp/.hidden in the example below). I want the zip file to have a top level folder which would be temp in the example below, hence ...
-3
votes
2answers
337 views

Using an shell glob (wildcard (*)) after a double quoted variable expansion

I read that it is a best practice to double quote all of your variable expansions in Bash. I also read that one cannot use a shell glob (wildcard(*)) right after a double quoted variable expansion. ...
1
vote
1answer
176 views

Basic usage of /etc/cron/ (d): correct pattern for /etc/cron (daily/weekly/monthly)

I use Ubuntu 16.04 with Bash and I've created this extensionless, shebangless file /etc/cron.daily/cron_daily: for dir in "$drt"/*/; do if pushd "$dir"; then wp plugin update --all --allow-root wp ...
3
votes
5answers
166 views

How to execute many files in the same directory in a minimal, DRY, pretty way?

I use Ubuntu 16.04 and I have a localization file, a file that executes many files, that I got after downloading my own GitHub project to my machine. This file contains a Bash script, and is named ...
0
votes
1answer
90 views

Execution of a remote Bash script in GitHub fails with various methods - Maybe due to Windows10

I have this remote Bash script In GitHub that I already executed successfully line by line, several times (in different versions). As it is quite frustrating to copy paste all lines each test, I ...
7
votes
2answers
1k views

How to export a large list of variables in Bash? [duplicate]

I use Bash 4.3.48(1) and I have a .sh file containing about 20 variables right under the shebang. The file contains only variables. This is the pattern: x="1" y="2" ... I need to export all these ...
11
votes
6answers
2k views

Too many shebang (script declaration) lines — any way to reduce their amount?

I have a project comprised of about 20 small .sh files. I name these "small" because generally, no file has more than 20 lines of code. I took a modular approach because thus I'm loyal to the Unix ...
1
vote
1answer
56 views

How to use one path in heredocument

I wrote this here-document to source a few scripts under the path ~/own_scripts/ but I wrote it in a way that causes duplication of this path: source <<-EOF ~/own_scripts/1.sh ~/own_scripts/...
1
vote
2answers
266 views

From multiline heredocument to a uniline herestring, with line breaks

I have this multilinie heredocument which I desire to translate into a uniline herestring: cat <<-"PHPCONF" > /etc/php/*/zz_overrides.ini [PHP] post_max_size = 200M upload_max_filesize ...
0
votes
4answers
155 views

What's the pattern in terminal commands?

Just starting to dive into the terminal thanks to the fun Raspberry Pi. I have one thing in particular that still has me scratching my head: I'm noticing the different daemons / services / processes /...
1
vote
2answers
64 views

How does '-' work in bash redirection?

I have seen this explained somewhere before but can't find a reference now. An example usage from docker getting started guide for Ubuntu: curl -fsSL https://download.docker.com/linux/ubuntu/gpg | ...
3
votes
1answer
212 views

Breaking long lines with comparison operators in a shell script

in my bash code sometimes I use long parameters in Comparison Operators to test the "OR" as the following: if [[ $production_check_linux_disks_quantity == false ]] || [[ $...
5
votes
2answers
686 views

Why is `source ~/.bash_aliases` exiting with syntax error?

What is the syntax error in this file? I can't spot it. set-k8s-azure() { export KUBECONFIG=~/.kube/config.azure-1 } set-k8s-minikube() { export KUBECONFIG=~/.kube/config.minikube } minikube() {...
-2
votes
1answer
1k views

What does $a and -e mean in sed? [closed]

[desktop ~]$ cat sa sanmesh shammas sujil givin nepo bijal [desktop ~]$ sed -i -e '1i Header' -e '$a Trailor' sa [desktop ~]$ cat sa Header sanmesh shammas sujil givin nepo bijal Trailor
0
votes
0answers
141 views

HP:the arguments in killall beyond `man killall`

In the tutorial here : /usr/bin/killall -HUP rsyslogd For the command : /usr/bin/killall -HUP rsyslogd In my os,the synopsis info in man killall SYNOPSIS killall [-Z, --context pattern] [-...