/absolute/path/to/someFile
Flag | Default value | Usage |
---|---|---|
-a arch --arch=arch | current | download packages for the arch architecture |
-d --delete | delete local packages no longer present in repository | |
--download-metadata | download all the non-default metadata | |
-p destDir --download_path=destDir |
current dir | download packages to destDir |
-g --gpgcheck |
|
|
-n --newest-only | download only newest packages per-repo | |
-l --plugins | enable yum plugin support | |
-r repoId --repoid=repoId |
all |
|
-u --urls |
|
Flag | Usage |
---|---|
-e packageName --erase packageName |
erase (i.e. uninstall) packageName |
-i packageName --install packageName |
|
-U packageName --upgrade packageName |
ugrade packageName = install new version + remove old version |
-q [selectOptions] [queryOptions] --query [selectOptions] [queryOptions] |
query the RPM database, with :
|
Since return outputs status codes (aka exit codes), it allows calling a function and processing its return value with && and ||.
#!/usr/bin/env bash returnParameter() { return $1; } trueThenReturnParameter() { true; return $1; } falseThenReturnParameter() { false; return $1; } returnTrue() { true; return; } returnFalse() { false; return; } for testValue in 0 1 2 42 '' x; do returnParameter $testValue; returnedValue1=$? trueThenReturnParameter $testValue; returnedValue2=$? falseThenReturnParameter $testValue; returnedValue3=$? echo -e "test value : '$testValue'\treturned values : '$returnedValue1'\t'$returnedValue2'\t'$returnedValue3'\n" done echo returnTrue && echo 'returned TRUE' || echo 'returned FALSE' returnFalse && echo 'returned TRUE' || echo 'returned FALSE'
test value : '0' returned values : '0' '0' '0' test value : '1' returned values : '1' '1' '1' test value : '2' returned values : '2' '2' '2' test value : '42' returned values : '42' '42' '42' test value : '' returned values : '0' '0' '1' ./test.sh: line 4: return: x: numeric argument required ./test.sh: line 9: return: x: numeric argument required ./test.sh: line 14: return: x: numeric argument required test value : 'x' returned values : '2' '2' '2' returned TRUE returned FALSE
read F2 ^[OQ Shift-F2 ^[[1;2Q Ctrl-F2 ^[[1;5Q
Flag | Usage |
---|---|
-a myArray | "explode" substrings of the parameter into elements of myArray. Consider IFS to identify such substrings |
-d delim | the 1st character of delim is used to terminate the input line, rather than newline |
-p prompt variableName | An example is worth 1000 words :
read -p "What's your name ? " yourName; echo "Hello $yourName"
What's your name ? Bob Hello Bob |
-r | raw input : disables interpretation of backslash escapes and line-continuation in the read data |
a b c zinto this :
a b c d e f g y z
Flag | Usage |
---|---|
-f | force resize2fs to proceed with the filesystem resize operation, overriding some safety checks it normally enforces |
Flag | Usage |
---|---|
-n newNiceValue |
|
-p PID |
[1] 19145 19145 (process ID) old priority 0, new priority 5
[1] 19167 19167 (process ID) old priority 0, new priority 5Same as above since -n is optional.
[1] 19208 19208 (process ID) old priority 0, new priority 5 19208 (process ID) old priority 5, new priority 5You can not renice an already reniced process (or at least, not like this).
[1] 19251 19251 (process ID) old priority 0, new priority 5 19251 (process ID) old priority 5, new priority 5The + sign seems to make no big difference.
[1] 19272 19272 (process ID) old priority 0, new priority 5 renice: failed to set priority for 19272 (process ID): Permission denied
[1] 20538 20538 (process ID) old priority 0, new priority 5 20538 (process ID) old priority 5, new priority 6
regular file | symlink | |
---|---|---|
readlink | (no result + causes an error) | link target, either relative or absolute, depending on how the link was set |
readlink -f | absolute path | absolute path of target |
realpath |
cd /tmp; touch myFile; ln -s myFile linkRelative; ln -s /tmp/myFile linkAbsolute for i in myFile linkRelative linkAbsolute; do a=$(ls -l "$i") b=$(readlink "$i") c=$(readlink -f "$i") d=$(realpath "$i") cat <<-EOF ls -l : '$a' readlink : '$b' readlink -f : '$c' realpath : '$d' EOF done rm myFile linkRelative linkAbsolute
ls -l : '-rw------- 1 bob users 0 août 6 15:31 myFile' readlink : '' readlink -f : '/tmp/myFile' realpath : '/tmp/myFile' ls -l : 'lrwxrwxrwx 1 bob users 6 août 6 15:31 linkRelative -> myFile' readlink : 'myFile' readlink -f : '/tmp/myFile' realpath : '/tmp/myFile' ls -l : 'lrwxrwxrwx 1 bob users 6 août 6 15:31 linkAbsolute -> /tmp/myFile' readlink : '/tmp/myFile' readlink -f : '/tmp/myFile' realpath : '/tmp/myFile'
Flag | Usage |
---|---|
-i | ask for confirmation before deleting each target file |
-f | force delete |
-r | delete recursively |
which rename /usr/bin/rename ll /usr/bin/rename lrwxrwxrwx 1 root root 24 juil. 1 09:25 /usr/bin/rename -> /etc/alternatives/rename ll /etc/alternatives/rename lrwxrwxrwx 1 root root 20 juil. 1 09:25 /etc/alternatives/rename -> /usr/bin/file-renameor even shorter :
realpath $(which rename) /usr/bin/file-rename
Flag | Usage |
---|---|
-n | no action : show how files would have been renamed |
prefix='testFile_'; extension='.ext'; for i in {1..20}; do touch "$prefix$i$extension"; doneFor the files 1 to 9 to be numbered 01 to 09, just run :
prefix='testFile_'; rename 's/_([0-9]\.)/_0$1/g' $prefix*
$prefix
is used to avoid affecting all files with a rename regExp *
(
)
(no need to escape parens), and is recalled as $n
(not \n
), n being the nth matched substring [youtubeVideoID]
part out (including brackets and leading space) :
s/ \[[^\]]+]//
' *webm highlighted brackets are those aboves/^([0-9]{2} )/$1- /
' *extensions/-[A-Za-z0-9]{6}\././
' *extensions/\([0-9]\)\././
' *extensions/^[0-9a-zA-Z]{32}_([0-9a-zA-Z]{8}\.[a-z]{3,4})/$1/
' *extensionmyfile_123 MYFILE_123
y/A-Z/a-z/; s/^(.*)$/$1'$suffix'/
' * && rename 's/^(.*)'$suffix'$/$1/
' *"$suffix"y/A-Z/a-z/; s/^(.*)\$/\$1$suffix/
" * && rename "s/^(.*)$suffix\$/\$1/
" *"$suffix"-rwxrwx--- 1 root 98 0 nov. 7 16:43 MYFILE.EXTENSION -rwxrwx--- 1 root 98 0 nov. 7 16:43 myfile.extension