Skip to main content
added 2 characters in body
Source Link

You should use the command-line argument variables $1, $2, $3, etc. $1 is automatically set to the first word after the command on the command line. $2 is the second word. $3$3 is the third, etc. You can also use the variable $#, which contains the number of arguments on the command line, to see if there are any arguments.

So your script would be:

#!/bin/bash if [ $# -gt 0 ]; then var="$1" else read var fi if [ "$var" == upd ]; then sudo pacman -Syyu; yay -Syu fi 

Note: You should ALWAYS put quotation marks around any variable that could contain spaces, especially if the variable might come from user input.

You should use the command-line argument variables $1, $2, $3, etc. $1 is automatically set to the first word after the command on the command line. $2 is the second word. $3 is the third, etc. You can also use the variable $#, which contains the number of arguments on the command line, to see if there are any arguments.

So your script would be:

#!/bin/bash if [ $# -gt 0 ]; then var="$1" else read var fi if [ "$var" == upd ]; then sudo pacman -Syyu; yay -Syu fi 

Note: You should ALWAYS put quotation marks around any variable that could contain spaces, especially if the variable might come from user input.

You should use the command-line argument variables $1, $2, $3, etc. $1 is automatically set to the first word after the command on the command line. $2 is the second word. $3 is the third, etc. You can also use the variable $#, which contains the number of arguments on the command line, to see if there are any arguments.

So your script would be:

#!/bin/bash if [ $# -gt 0 ]; then var="$1" else read var fi if [ "$var" == upd ]; then sudo pacman -Syyu; yay -Syu fi 

Note: You should ALWAYS put quotation marks around any variable that could contain spaces, especially if the variable might come from user input.

added 2 characters in body
Source Link

You should use the command-line argument variables $1, $2, $3, etc. $1 is automatically set to the first word after the command on the command line. $2 is the second word. $3 is the third, etc. You can also use the variable $#, which contains the number of arguments on the command line, to see if there are any arguments.

So your script would be:

#!/bin/shbash if [ $# -gt 0 ]; then var="$1" else read var fi if [ "$var" == upd ]; then sudo pacman -Syyu; yay -Syu fi 

Note: You should ALWAYS put quotation marks around any variable that could contain spaces, especially if the variable might come from user input.

You should use the command-line argument variables $1, $2, $3, etc. $1 is automatically set to the first word after the command on the command line. $2 is the second word. $3 is the third, etc. You can also use the variable $#, which contains the number of arguments on the command line, to see if there are any arguments.

So your script would be:

#!/bin/sh if [ $# -gt 0 ]; then var="$1" else read var fi if [ "$var" == upd ]; then sudo pacman -Syyu; yay -Syu fi 

Note: You should ALWAYS put quotation marks around any variable that could contain spaces, especially if the variable might come from user input.

You should use the command-line argument variables $1, $2, $3, etc. $1 is automatically set to the first word after the command on the command line. $2 is the second word. $3 is the third, etc. You can also use the variable $#, which contains the number of arguments on the command line, to see if there are any arguments.

So your script would be:

#!/bin/bash if [ $# -gt 0 ]; then var="$1" else read var fi if [ "$var" == upd ]; then sudo pacman -Syyu; yay -Syu fi 

Note: You should ALWAYS put quotation marks around any variable that could contain spaces, especially if the variable might come from user input.

added 1 character in body
Source Link

You should use the command-line argument variables $1, $2, $3, etc. $1 is automatically set to the first word after the command on the command line. $2 is the second word. $3 is the third, etc. You can also use the variable $#, which contains the number of arguments on the command line, to see if there are any arguments.

So your script would be:

#!/bin/sh if [ $# -gt 0 ] ]; then var="$1" else read var fi if [ "$var" == upd ] ]; then sudo pacman -Syyu; yay -Syu fi 

Note: You should ALWAYS put quotation marks around any variable that could contain spaces, especially if the variable might come from user input.

You should use the command-line argument variables $1, $2, $3, etc. $1 is automatically set to the first word after the command on the command line. $2 is the second word. $3 is the third, etc. You can also use the variable $#, which contains the number of arguments on the command line, to see if there are any arguments.

So your script would be:

#!/bin/sh if [ $# -gt 0 ] then var="$1" else read var fi if [ "$var" == upd ] then sudo pacman -Syyu; yay -Syu fi 

Note: You should ALWAYS put quotation marks around any variable that could contain spaces, especially if the variable might come from user input.

You should use the command-line argument variables $1, $2, $3, etc. $1 is automatically set to the first word after the command on the command line. $2 is the second word. $3 is the third, etc. You can also use the variable $#, which contains the number of arguments on the command line, to see if there are any arguments.

So your script would be:

#!/bin/sh if [ $# -gt 0 ]; then var="$1" else read var fi if [ "$var" == upd ]; then sudo pacman -Syyu; yay -Syu fi 

Note: You should ALWAYS put quotation marks around any variable that could contain spaces, especially if the variable might come from user input.

added 1 character in body
Source Link
Loading
added 9 characters in body
Source Link
ilkkachu
  • 148.2k
  • 16
  • 268
  • 441
Loading
added 2 characters in body
Source Link
Loading
deleted 1 character in body
Source Link
Loading
added 1 character in body
Source Link
Vlastimil Burián
  • 31.3k
  • 67
  • 211
  • 359
Loading
Source Link
Loading