Skip to content

Instantly share code, notes, and snippets.

@Jongbhin
Last active March 30, 2022 02:31
Show Gist options
  • Save Jongbhin/373e19182aa61a734e28282737a7863e to your computer and use it in GitHub Desktop.
Save Jongbhin/373e19182aa61a734e28282737a7863e to your computer and use it in GitHub Desktop.
[bash reference] #bash #reference

Study material

http://linuxcommand.org/lc3_wss0120.php

Working directory of running process

pwdx <PID>

print time, date, execution time

print time

start_time=$(date +"%T")
echo "Start time : $start_time"

print execution time

start=`date +%s`
stuff
end=`date +%s`

runtime=$((end-start))

find and replace string in file

sed -i -e 's|abc|XYZ|g' some_file

find and replace string in file recursively

find . -type f -name "*.txt" -print0 | xargs -0 sed -i '' -e 's/foo/bar/g'

find . -type f -name "*.json" -exec sed -i'' -e 's|string_to_find|string_to_replace|g' {} +

filter curlm value

awk '{ if ($7 == 6) { print } }' pos_cut1-5.txt | head
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment