man bash
--
signals the end of options and disables further option processing. Any arguments after the -- are treated as filenames and arguments. An argument of - is equivalent to --
-v
с помощью grep в текстовом файле: grep -- -v file.txt
, если не добавить --
, то grep воспримет -v
, как свою опцию, а не подстроку для поиска.#!/bin/bash -e
main() {
curl --output /dev/null \
--header "Authorization: Bearer $1" \
--silent \
--request PUT \
--data-binary @appilication.yml \
--insecure https:/$2/v1/kv/config/test/test/test/data
}
main token_for_example1 example1.consul.com
main token_for_example2 example2.consul.com
#!/bin/bash -e
template="blanc.docx"
student_list="ФИО.txt"
output_dir="certificate"
tmp_d="tmp_word"
mkdir -p "$tmp_d" "$output_dir"
unzip "$template" -d "$tmp_d"
cp "$tmp_d/word/document.xml" .
while read -r student_name; do
echo -e "\n\033[0;32m${student_name}\033[0m"
cp document.xml "$tmp_d/word/document.xml"
sed -i "s/????/$student_name/g" "$tmp_d/word/document.xml"
cd "$tmp_d"
zip -r "../$output_dir/$student_name.docx" *
cd ..
done < "$student_list"
rm -rf document.xml "$tmp_d"
echo '10.0.0.8/8, 10.0.0.12/8, 10.0.0.123/8, 10.0.0.8/8' | sed 's|/8|/32|g'
# результат
10.0.0.8/32, 10.0.0.12/32, 10.0.0.123/32, 10.0.0.8/32
результат выглядит просто как Address = 10.0.0.{1,3}/32.
#!/bin/bash
# uncomment for debug
#set -x
function get_avg_size() {
[ ! -d "$1" ] && echo "Directory $1 DOES NOT exists." && exit 1
sum_size=0
count=0
for size in $(LC_ALL=C stat -c '%F %s' $1/* | grep 'regular file' | cut -d ' ' -f 3); do
let sum_size=$sum_size+$size
let count=$count+1
done
echo "Average file size $(($sum_size/$count))"
}
get_avg_size ~/
find -maxdepth 1 -type f -printf "%CD %CT \t%AD %AT\t%TD %TT\t%p\n"
02/11/22 06:12:13.2894161360 02/11/22 06:12:13.2894161360 02/09/22 15:39:58.0406894530 ./.bash_history
12/23/21 06:47:45.6371287180 02/10/22 08:38:18.3691395020 10/11/21 08:53:17.7579489750 ./.bash_aliases
...
man find
найди там описание -ptinf и выбери нужный тебе формат даты и времени.