Questions tagged [syntax]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0
votes
0answers
39 views

How to make --exclude-glob work with this use case of lftp and fish shell?

I have a statement that looks like this: set cmd 'set ssl:verify-certificate false; open -u abc,def ftp.somewhere.com; mirror --only-newer --exclude-glob "{.git|node_modules|wp-config.php}" \...
0
votes
2answers
94 views

;ls bash: syntax error near unexpected token `;'

after typing ;ls I got this return - bash: syntax error near unexpected token `;' how do I fix this?
0
votes
1answer
22 views

shell programming syntax error [closed]

num1 = 20 num2 = 20 echo $(( num1 + num2 )) echo $(( num1 - num2 )) echo $(( num1 * num2 )) echo $(( num1 / num2 )) echo $(( num1 % num2 )) Error : ./practice.sh: line 53: num1: command not found ./...
0
votes
0answers
31 views

Meaning of this cycle term in this sed command

Given i once asked this question, i tried to understand how the answer's solution worked. I tried to read more about sed to do so, but while i managed to understand most of how it worked, I noticed ...
0
votes
1answer
39 views

How do I fix this syntax error from awk in my shell script?

I have a script with two codes to pull the sum of data of a given file and print to another file and a second pulls the total number of missing data points to another file. Finally the two output ...
634
votes
5answers
233k views

What does “--” (double-dash) mean?

I have seen -- used in the compgen command. For example: compgen -W "foo bar baz" -- b What is the meaning of the -- in there?
0
votes
0answers
36 views

Why does & work instead of &; for forks in 1 line bash loop [duplicate]

If you write a 1 line shell script that forks a process, like the following: for i in {1..1000};do ./binary & done It runs, you don't need a semicolon, and if you try to use a semicolon it throws ...
0
votes
1answer
88 views

What is the intended purpose of the () syntax in a bash function?

I am freshening up my bash skills. I use the term skills very loosely; I've been outta the game a long time. So, as a way to brush up, I decided to code something utilizing bash/zenity/yad. I read man ...
0
votes
0answers
58 views

What happens when we use ampersand `&` at the end of the pipeline? [duplicate]

Normally, when we use a pipe, the operations on the left and right of the pipe are run in separate subprocesses. The outputs of the first command are transmitted as input to the second command. In ...
1
vote
1answer
478 views

bash can't find closing bracket?

I am writing a bash script to makup the MariaDB instance on a Synology box. When I run it, it works, but I get an error: admin@synology:/volume1/@appstore/MariaDB10/usr/local/bip$ ./mysql_backup ./...
0
votes
1answer
18 views

NVRAM Variable syntax

I'm trying to edit the client_customlist variable in my router with Merlin firmware, and am a bit confused with the syntax; when I export it and then look at it, most of them end with 3 >, like ...
17
votes
1answer
4k 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 ...
2
votes
2answers
288 views

Difference between GNU find -not and GNU find -prune -o -print

This answer on opening all files in vim except [condition]: https://unix.stackexchange.com/a/149356/98426 gives an answer similar to this: find . \( -name '.?*' -prune \) -o -type f -print (I adapted ...
0
votes
0answers
45 views

Conky script not running after being converted

I am attempting to convert an older conky widget to the new syntax of 1.10+, but I can't for the life of me figure out why it won't run. I've ran through everything to make sure it was converted ...
0
votes
4answers
78 views

Awk if condition error [closed]

I have written an awk command which filters based on a condition awk '{if(( (substr($0,9,3) == "TGO") && ((substr($0,1,4) == "9123" || (substr($0,1,4) == "9704"))...
0
votes
1answer
204 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] [-...
1
vote
1answer
44 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 ...
1
vote
4answers
113 views

What's the difference between if ! [[ foo ]] and if [[ ! foo ]] in Bash?

I understand that ! is used to negate an if condition in Bash, but I've just seen code which takes the format: if ! [[ CONDITION ]]; then SOMETHING fi Is there a difference between this format ...
0
votes
1answer
25 views

quasi nested conditions in bash is failing, because of elif syntax error

I have code that performs some conditionals in bash: firstchar=$(head -c 1 /tmp/project.json) if [ $? -eq 0 ] then; echo "Hooray! nothing found" elif [ $? -eq 1 ]; then ...
4
votes
3answers
141 views

Compare two files on specific columns only line by line

What is the syntax inside for loop if i in [2,4,7] in awk. Also any idea how to achieve to do in below code. Thanks Input : $ cat f1 col1,col2,col3,col4,col5,col6,col7 col11,col12,col13,col14,col15,...
-1
votes
1answer
115 views

How to fix the error near unexpected token `else'

I am getting a syntax error at line 17 : unexpected token `else' declare -i A echo "enter any numeric value" read value if [$value > 0]; if [[ "$value" =~ ^[0-9]+$ ]]; ...
-2
votes
1answer
35 views

Unifiyng lines with awk

I have the file/text bellow: apple 1 apple 2 apple 3 banana 22 banana 5 string 1 How can I run a command to return the following result? apple numbers:1,2,3 banana numbers:22,5 string numbers:1
2
votes
1answer
44 views

How do you interpret this complicated man page syntax?

I am reading this on a man page: [-n number-to-stat[:max-size[:min-size][:num-directories[:chunk-size]]]] I interpret this as -n is optional but how do I specify the num-directories? Preferably I ...
-1
votes
1answer
44 views

Python Error | Basic

i tried to run this code: cd sudo apt-get -y install firefox cd wget https://github.com/mozilla/geckodriver/releases/download/v0.26.0/geckodriver-v0.26.0-linux64.tar.gz tar xzf geckodriver-v0.25.0-...
-1
votes
1answer
38 views

How to pass brackets to some program's arguments?

I am trying to execute the command like this python train.py --conv-layers [(512, 10, 5), (512, 8, 4)] but bash swears -bash: syntax error near unexpected token `(' I need train.py receive exactly ...
4
votes
3answers
477 views

Is it possible to have conditionals in /etc/rc.local?

Is it possible to have a conditional within /etc/rc.local? I've checked many Q&As and most people suggest running chmod +x on it, but my problem is different. It actually does work for me without ...
0
votes
1answer
53 views

What is the difference between sending carbon copies of mail message to other users and sending mail to multiple users at the same time

In Unix, the -c option in mailx command sends copy of message to other people and has the following syntax: mailx -s "Subject" -c "jpm,sumit" charlie < message.txt where jpm ...
20
votes
1answer
2k views

Using mv command to move a file from one folder to another one - Strange example

I'm learning unix commands from a UNIX Tutorial for Beginners at surrey.ac.uk where I found a weird way to move a file. In particular, I have the folder unixstuff in the home directory, inside the ...
0
votes
0answers
37 views

Syntax for using systemd-run to limit CPU and memory usage of multiple processes?

I would like to use Linux control groups (cgroups) to limit CPU and RAM usage of multiple processes. If the processes are Process 1 and Process 2 with child process Process 2 Sub, would this be the ...
-1
votes
1answer
152 views

How to search OpenStreetMap for tags? [closed]

How can I have e.g. all highway speed cameras displayed on the map, i.e. what is the URL syntax to search OpenStreetMap for certain tags?
2
votes
1answer
241 views

How do I syntax check a Zsh script?

I can do it in bash using bash -n script.sh command. is this possible in zsh?
3
votes
1answer
187 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=&...
0
votes
0answers
48 views

How can I find out what experimental syntaxes my current version of Docker supports?

When I run an experimental syntax I get the following Error response from daemon: Dockerfile parse error line 13: Unknown flag: security When I run with DOCKER_BUILDKIT=1 I get, I get, [+] Building ...
-2
votes
1answer
4k 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
2answers
41 views

Why are these particular semicolons necessary in this function definition and command-line?

I'm preparing for the LPIC1, exam 102. This question came my way and I absolutely blanked. I knew it when I first took the quiz, now a month and a half later it's all blurred in my head. What does ...
19
votes
4answers
2k views

Preferred syntax for two lines long pipe [closed]

When writing a long pipe it is usually clearer to separate it in two lines. This long command line: ruby -run -e httpd -- -p 5000 . 2>&1 | tee >(grep -Fq 'WEBrick::HTTPServer#start' &&...
0
votes
1answer
160 views

^ syntax error in awk when called via ssh

I'm running filesystem usage command to detect /var filesystem usage beyond 80% from one host to multiple remote hosts. My command runs fine (df -h /var | awk '$1 > 80'), but with ssh it gives me ...
0
votes
1answer
145 views

What is precisely the role of the '&' character in a bash/shell redirection? [duplicate]

So as I'm writing my own shell for school, I have to implement redirections. I've looked at the GNU Bash manual, and a fair amount of tutorials, but I'm still having troubles understanding what ...
-7
votes
5answers
3k views

What is masking a mode?

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

what `foo=bar programname` means [duplicate]

While developing a React app, I needed to use some environment variables. The way to do it is by using this syntax: REACT_APP_NOT_SECRET_CODE=abcdef npm start see reference My first question is: ...
2
votes
1answer
35 views

Temporary display full name of argument instead of short name/abbrev

After an command, where the user should give an output location with -o, I wondered if there is an (standard) command that temporary displays the full name of the given argument, like the -o, that ...
1
vote
1answer
163 views

Problem with auto-completion on VPS

I just set up a VPS with hostinger.com. The OS is Ubuntu 18.04. I created a user account, mike. I quickly realised that auto-completion wasn't apparently installed so looked up how you do this. For ...
2
votes
1answer
153 views

Consolidate several GraphicsMagick (ImageMagick) commands into one

There are many times I get single page PDFs that I want to convert to JPEGs and crop the excess whitespace off of. Here is the current set of commands I have which accomplishes what I want: gm ...
0
votes
1answer
180 views

bash script single quote and backslash creation

I'm trying to write a bash script for a snapshot backup with rsync to a server. The command I want to invoke is rsync -aPh -e ssh --rsync-path='sudo rsync' --link-dest=../last /home/username/files ...
0
votes
1answer
187 views

iptables command is not accepted in parrot OS

I created my own chain called test. I want to insert a new rule in the chain that drops all packets to an IP address at a specified port. sudo iptables -I test -j DROP -d 130.x.y.z -dport 24 The ...
4
votes
3answers
3k views

I am getting “syntax error near unexpected token `'$#''” in a simple Bash script

I'm using Debian 10 (Buster) and am getting an error in a simple Bash script. All it does is check to see if one parameter is passed in, and if it's a file, just echo out the file: #!/usr/bin/bash if ...
1
vote
1answer
117 views

Why should I set the source device with < > when using pv?

I have a question out of curiosity ;-) I find that I could accomplish cloning a disk with the command pv instead of dd too. For that I used what I found in the internet pv < /dev/sda1 > /dev/...
11
votes
1answer
694 views

Why can't you reverse the order of the input redirection operator for while loops?

In Bash you can move input redirection operators to the front of a command: cat <<< "hello" # equivalent to <<< "hello" cat Why are you unable to do the same for while loops? ...
-2
votes
2answers
70 views

Help with indexing a list of values

I need to track a huge log and more exactly a column. In this column I have some integer values in a rage between 103 and 17431. Example of original file 402 402 402 667 942 342 990 402 For every ...
-1
votes
2answers
86 views

Defining several variables at once (copy-paste-execute in shell)

I have a list of variables I copy-paste one by one from a file to my shell and hit Enter to execute. For example: var1="myvar1" var2="myvar2" Because in practice there are more variables, instead ...