Questions tagged [syntax]

Syntax refers to the rules of programming languages which stipulate how code is to be arranged so that the structure is syntactically correct and can be executed successfully in the particular framework of those languages.

Filter by
Sorted by
Tagged with
48 votes
3 answers
23k views

Write function in one line into ~/.bashrc

Why when I try to write a function just in one line into .bashrc file, list(){ ls -a } I get error? bash: /home/username/.bashrc: line num: syntax error: unexpected end of file but when I write it ...
αғsнιη's user avatar
  • 35.7k
38 votes
4 answers
97k views

How to format "if" statement (conditional) on multiple lines in bash?

I have a Bash shell function that takes an argument and performs something on it if needed. do_something() { if [need to do something on $1] then do it return 0 else return 1 fi } ...
Itay's user avatar
  • 663
26 votes
4 answers
21k views

What is the difference between standard syntax and BSD syntax?

I have seen many commands that accept a "BSD syntax" as well as their standard syntax. Take the ps command for one example: To see every process on the system using standard syntax: ps -e ...
Mohammad Reza Rezwani's user avatar
17 votes
7 answers
11k views

What is the point of the bash Null-operator ":", colon?

What is the point of the "null" operator in a BASH script? I understand that it is used as a placeholder following an if command when you have nothing to say, but need a command to allow the program ...
Justin's user avatar
  • 2,111
16 votes
3 answers
5k views

What does this syntax mean?

I am new to terminal and trying to learn how to use it. What do these lines do? And how do they work? echo -n "Today's date is: " date +"%A, %B %-d, %Y"
Unknown person's user avatar
15 votes
2 answers
21k views

Run another command when previous command completes [duplicate]

Today I opened gnome-terminal and I wrote ls && sleep 4 && gnome-terminal to open another terminal after the completion of ls command and waiting for 4 seconds. So it successfully ...
Abhishek Kamal's user avatar
15 votes
2 answers
2k views

What's the missing argument to -exec?

I use the following command to clear a directory, of files and directories over 30 days old, and move them to an archive directory which I can delete after a few weeks if nobody asks for their files ...
Arronical's user avatar
  • 19.9k
13 votes
2 answers
6k views

command output redirection using '-< <( ... )'

I needed to extract a shasum. This works, but can anyone explain why? sed 's/^.*= //' -< <(openssl dgst -sha256 filename) I'm familiar with the $( ) construct, but can't find docs for <( ), ...
GlenH's user avatar
  • 133
12 votes
2 answers
11k views

For loop with Alphabet

This works perfectly on OSX #!/bin/bash chars=( {a..z} ) n=3 for ((i=0; i<n; i++)) do echo "${chars[i]}" done But when I run it on Ubuntu, I get the following error. ForLoopAlphabetTest.sh: 2: ...
denski's user avatar
  • 331
11 votes
2 answers
7k views

meaning of "'" (apostrophe) in terminal commands

For some weird reason, I tried "'" as word separator in identifiers, as in: $ export foo'bar=1 > > ^C $ The result is as shown above, id est the prompt changes to ">" and the system ...
denis 63's user avatar
  • 111
10 votes
3 answers
198k views

"Syntax error: Unterminated quoted string"

I am trying to use a backup script that will backup my sql database and website files. I am running Ubuntu 12.04 32 bit version and zPanel. Also what are these variables: MYSQL="$()" MYSQLDUMP="$()" ...
Hamza's user avatar
  • 111
10 votes
1 answer
9k views

What does the syntax of pipe and ending dash mean? [duplicate]

Disclaimer. I'm a long-time Windows user and just starting to get my head around the Linux paradigm. While excited by it, I understand that my formulations might be poorly chosen due to ignorance. I'...
Konrad Viltersten's user avatar
9 votes
5 answers
2k views

Why is a blank required between "[[" and "-e xxx" in ksh?

For instance, the following command does not work: if [[-e xyz]]; then echo File exists;fi ksh gives the following error [[-e: command not found Is that because "[[-" is ambiguous?
AcBap's user avatar
  • 93
9 votes
1 answer
2k views

Brackets, Braces, Curly Brackets in Bash

Here goes the riddle: If I do: touch file{1,2,3} It creates file1, file2, file3 And if I do rm file[1-3] It deletes them. but if I do touch file[1-3] it creates: file[1-3] Why?
Ulukai's user avatar
  • 385
8 votes
1 answer
7k views

Can I enable bracket matching in nano?

else if( d && ( (d <= b && d <= s) || (!b && !s) ) smallest = d Consider this piece of code of C++. Can we have bracket matching (highlighting opening bracket when ...
owsmmj's user avatar
  • 301
7 votes
3 answers
18k views

how do I fix youtube-dl: running it gives error message about incorrect syntax

I recently installed 22.04 completely from scratch. Just now I followed instructions to install youtube-dl, with wget (from github.com): sudo wget https://yt-dl.org/downloads/latest/youtube-dl -O /usr/...
Akpglt's user avatar
  • 83
6 votes
2 answers
1k views

syntax error: unexpected end of file .bash_profile

I added the below code to empty ~/.bash_profile file and after restarting and login via ssh to the server I get syntax error: unexpected end of file .bash_profile NODE_ENV=production if [ -f ~/....
Sami's user avatar
  • 71
5 votes
3 answers
7k views

How to fix ~/.profile and ~/.bashrc syntax errors

Ubuntu 18.04.4 (automatic upgrade from 18.04.3 just a few weeks ago) /bin/bash After I log in from the Gnome shell, this message appears while the screen is just plain purple and before the desktop ...
Hedley Finger's user avatar
5 votes
1 answer
7k views

what does the -aux option of ps stand for?

You often pass options to CLI commands which cause the function to behave differently. They all have a meaning, for example -v means "Verbose" -l means "List" The ps command lists all running ...
ShiverFlame's user avatar
5 votes
1 answer
2k views

Add a tag to jpeg using ExifTool

I would like help with terminal syntax code please to add a tag to jpeg files using ExifTool. I want to add general notes to some old scanned jpeg pictures of my ancestors for my kids to be able to ...
Marty's user avatar
  • 117
4 votes
3 answers
8k views

Is the command line structure the same for Linux and Ubuntu?

I'm new to the Linux world. I'm curious to know if the command line syntax is the same between Linux and Ubuntu?
thesonofman's user avatar
4 votes
3 answers
58k views

How do I send GET and POST requests using Curl?

How do I send GET and POST requests with parameter gimmeflag and value please to the URL http://103.200.7.150:7777/ using curl on the command line?
raka widiana's user avatar
4 votes
1 answer
6k views

Can you do dictionaries in qml?

So for example: Item { id: sylvainLikesAnsweringMyQuestions property var myDict: {[key,value],[anotherKey,anotherValue]} }
Anon's user avatar
  • 12.1k
3 votes
3 answers
1k views

if command syntax

My code of shell script is as follows: echo "Enter file name"; read fname; if [-f$fname]; then echo "File already exists"; fi` However, when I run my script, I get this error: [-ffile]: not ...
Prachi's user avatar
  • 87
3 votes
2 answers
3k views

Subtracting dates formats in bash

I am trying to create a countdown - most likely the hard way. I have it setup like this: #! /bin/bash #When to execute command execute=$(date +"%T" -d "22:30:00") #Current time ...
CJ-Tech's user avatar
  • 45
2 votes
1 answer
9k views

Must apt-get install software-properties-common precede ppa:X?

This is how I currently install some basic software in my Ubuntu 18.04 server environment. I am afraid I might have some redundancy here: apt-get update -y apt-get install software-properties-common ...
user avatar
2 votes
1 answer
5k views

Can't uninstall PHPmyadmin in Ubuntu 16.04

My PHPmyadmin (PMA) install was stuck. I started a new session and when doing apt-get purge phpmyadmin I got: E: Could not get lock /var/lib/dpkg/lock - open (11: Resource temporarily unavailable)...
user avatar
2 votes
1 answer
1k views

How to install Maxima and make syntax on Ubuntu Server 18.04

How to install Maxima computer algebra system, and make a syntax like the screenshot that is shown below? What is a similar application to Maxima that can run from the command-line in Ubuntu Server 18....
Johan Kun Riyanto's user avatar
2 votes
1 answer
954 views

How to calculate Pi decimals from a given offset?

I am using http://packages.ubuntu.com/lucid/math/pi to calculate Pi decimals. Let's say I want only decimals from the 3rd decimal to the 5th decimal. man pi says it is possible to enter an interval ...
Nicolas Raoul's user avatar
2 votes
1 answer
1k views

Space literal as function name in bash

This question is loosely related to one of my previous ones. TL;DR from muru's answer is that characters in function name have to be on Portable Character Set in order to be valid for a function name. ...
Sergiy Kolodyazhnyy's user avatar
2 votes
0 answers
469 views

Colored syntax and terminal when using SSH from terminal

Ok. So I use pico as a text editor. In ubuntu and when I ssh using putty I have colored syntax and colored terminals. When I ssh through ubuntu terminal I have solid white text. I always ssh into my ...
DirtyDaver's user avatar
2 votes
0 answers
10k views

Xerox Work center JCL syntax error/ Printing error (016-749)

Its long since Xerox workcenter 5225 is not working with my ubuntu 32 bit. The new error i am receiving is that says JCL syntax error. Still gnome in ubuntu tells me printing is successful but it ...
Samir Chauhan's user avatar
1 vote
1 answer
13k views

-bash: syntax error near unexpected token `&'

I get this error (-bash: syntax error near unexpected token `&' ) when I run the command below: sudochown -hRfwebadmin:www-data /web/<repertoire>&&sudoln -s /web/<repertoire&...
tsilokomail's user avatar
1 vote
2 answers
8k views

linux shell script Syntax error: word unexpected (expecting "fi")

Below I have a shell script i wrote and when I try to execute it I get an error in my terminal describing the "expecting fi" keyword. I have written it down before the done keyword and have still not ...
Roosevelt Mendieta's user avatar
1 vote
2 answers
1k views

line 42: syntax error: unexpected end of file [closed]

I'm attempting to make a simply security log-in that prompts the user to input a name and then if said name matches one of the if statements, it proceeds to have them enter a password followed by an ...
Mr. Nobody's user avatar
1 vote
1 answer
239 views

syntax for creating variable out of command with apostrophe in it [closed]

NOOB level: horrible at syntax and regular expressions and BASH programming in general but learning and studying for the Lin+ I'd like to run this script but it doesn't like my syntax apparently. ...
thursDave's user avatar
  • 105
1 vote
1 answer
4k views

Conditions and ranges within case statements in bash

I was writing a plugin for Nagios to check the number of security packages and doing a case statement as the one here. but the whole thing ended up turning into a freak show. All I basically wanted ...
Ulukai's user avatar
  • 385
1 vote
1 answer
2k views

Python syntax error with awk, sprintf statment (2.7)

I am trying to use one of the shell commands to a python script, but struggling with some syntax error here. The description of the command is from here echo /dev/bus/usb/`udevadm info --name=/dev/...
Vikram's user avatar
  • 11
1 vote
1 answer
1k views

Gnuplot script bash problem

I have wrote this script in bash for f in $FILES do echo "Processing file... $f" # take action on each file. $f store current file name B=$(basename $f) filename="${B%.*}" mkdir $BASEDIR/$...
user5355783's user avatar
1 vote
2 answers
775 views

Shellcheck recommendation to double-quote variable does not work when piping to cut

I'm making a script to print ZFS filesystem info - currently in the testing phase, and I'm getting a strange error. The relevant bit of my initial script is this: zfs_human="$(zfs list | head -n ...
Artur Meinild's user avatar
1 vote
1 answer
182 views

Pluma/Gedit REMOVE languages

I like to remove most of the languages from the pluma/gedit menues, where they show up. It's great that the editors support so many languages. But most of them I never use. So they are only in the ...
user unknown's user avatar
  • 6,639
1 vote
1 answer
2k views

"E: Syntax error /etc/apt/apt.conf.d/10periodic:7: Extra junk at end of file" how to trouble shoot this? [duplicate]

I typed sudo apt update in terminal, then I got the following error: E: Syntax error /etc/apt/apt.conf.d/10periodic:7: Extra junk at end of file The file contains: 1 # 2 # Xilinx Clocking Wizard ...
Irshad Ahmed's user avatar
1 vote
1 answer
198 views

QML: How to display a "<" character in a richTextBox?

The code in question: description.insert(0,"<tr><td><H1> ---Less-Than-Sign-Here--- </H1></td><td><font face='Ubuntu'size='3'color='#f37420'> ...
Anon's user avatar
  • 12.1k
1 vote
1 answer
176 views

sudoers syntax different for server vs desktop?

Is there a difference in syntax between the server and desktop ubuntu 12.04 distro? If so could I get help rewriting this line to be valid for the desktop env? user1 ant =(user1) NOPASSWD: ~/progs/...
travega's user avatar
  • 221
1 vote
1 answer
97 views

problem bashrc file colored terminal

I have a problem with my terminal in Ubuntu server 20.04. I would like to color the syntax in my terminal, but after I restart the server, it's back to the normal uncolored syntax. I edited .bashrc ...
Dany's user avatar
  • 79
1 vote
3 answers
918 views

How do you get a *.desktop file to work for a non-repository app?

I turned the Amazon cloud reader site https://read.amazon.com into a desktop app with nativefier. It works amazingly well as a standalone reader for books that have been downloaded and also ...
Hedley Finger's user avatar
1 vote
0 answers
577 views

Can't save my sudoers.tmp file after correcting syntax error

I know there are a lot of questions regarding sudoer and sudoers.d directory, but i can't find the answers for my specific problems: There is a syntax error on every line (in both sudoer and sudoers....
redheadtri's user avatar
1 vote
1 answer
122 views

I cannot get grep to print results

Total noob here. I am blindly stumbling my way through bash. I realize that there is a syntax error in the following script but, I cannot figure it out. The script just sits there. #!/bin/bash mac=`...
Brian Hunking's user avatar
1 vote
0 answers
413 views

Syntax Error while running an install.sh file

I have a problem with a .sh file. This file will install a. Py file in the same folder! The file looks like this: #!/bin/bash/ python install.py "$ @" Can somebody pleace help me?
Simon's user avatar
  • 11
0 votes
1 answer
121 views

What happens if no destination is defined after > (redirection)?

recently I wanted to read the man pages for mplayer. So I needed to type man mplayer in the terminal. Yet out of clumsiness I typed man mplayer>. I know that I could redirect the output e.g. to ...
Rosika's user avatar
  • 575