Last active
October 4, 2022 19:02
-
-
Save kjivan/73b33cd745a44bf1fd3e9cd0eb912ba4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -e | |
# rm file | |
find . -name 'file.json' -exec rm {} \; | |
# replace strings in file | |
sed -i '' 's|find|replace|g' filename | |
# Remove line from file | |
sed -i '' '|deletestr|d' file | |
# delete string in certain extension files | |
find root_path -name '*.rs' -exec sed -i '' 's|find|d' {} \; | |
# send something to two files | |
echo 2-file-string | tee -a | |
file1 \ | |
file2 | |
# output multiple lines to file | |
printf "\ | |
lots of info | |
pre formatted | |
can go here | |
" | cat > file1 | |
# replace string in certain extension files | |
find root_path -name '*.rs' -exec sed -i '' 's|find|replace|g' {} \; | |
# check for string in file before replacing it | |
if grep -q SomeString "$File"; then | |
Some Actions # SomeString was found | |
fi | |
# check if file exists | |
FILE="/etc/passwd" | |
if [ -f $FILE ]; then | |
echo "$FILE exists" | |
else | |
echo "$FILE doesn't exist" | |
fi | |
# Increment number while replacing | |
gsed -r 's/(.*)(cache_version=)([0-9]+)(.*)/echo "\1\2$((\3+1))\4"/ge' test | |
# check if command exists | |
if ! command -v COMMAND &> /dev/null | |
then | |
echo "COMMAND could not be found" | |
exit | |
fi | |
# Remove files that have text | |
find -iname "*.txt" | xargs grep -l "Wij willen graag weten in welke omgeving" | awk '{print "rm "$1}' | bash | |
# Create symlinks to all executables | |
rm *; fd -t x . ../ -x ln -s {} | |
# Convert fish function to zsh/bash alias | |
cat aws.fish | sed 's|function|alias|g' | sed 's| -w "[^"]*"; |="|g' | sed 's|$argv|\\"$@\\"|g' | sed 's|; end|"|g' > aws.zsh |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment