Skip to content

Instantly share code, notes, and snippets.

Tanzeem Akhtar tanzyy

Block or report user

Report or block tanzyy

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View nested_dir_traverse_&_print_name.sh
#!/bin/bash
# This method finds last name separated by /, helps in getting directory or file name without path.
print_name() {
echo $1 | awk -F "/" '{ print $NF }'
}
dir_name=/Users/tanzyy/_temp/logshomedir/*
for d in $dir_name; do
View bash_multiline_comment.sh
#!/bin/bash
# This script shows how to make multiline comment. Indentation is mandatory inside "comment".
echo "This should get printed: Before multiline comment"
: <<'Comment'
echo "This should NOT get printed: Inside multiline comment"
Comment
View awk_pass_shell_variable.sh
#!/bin/bash
#This script shows how to pass shell variable to awk using option -v
index_pos="4"
search_string="31/Mar/2017:03:58:38"
cat ~/Desktop/tempp.txt | awk -v pos=$index_pos -v ss=$search_string '{ if($pos==ss) print $0 }'
@tanzyy
tanzyy / add_to_array.sh
Last active Apr 11, 2017
Shell | Add value to array
View add_to_array.sh
#!/bin/bash
# This script shows how to declare array and and add vlaues to it.
result=()
result+=('foo')
result+=('bar')
for i in "${result[@]}"
do
@tanzyy
tanzyy / dateloop.sh
Last active Mar 28, 2017
Loop with date (MAC)
View dateloop.sh
#!/bin/bash
# On MAC date -d option does not work rather -v.
# Below code logic is as follows:
# Create folders with date(in format YYYY-MM-DD) with consecutive dates until it reaches to input difference
# Here variable datediff is 28 meaning from current date, it will generate dates until there is difference of 28.
now=$(date -v -1d +"%Y-%m-%d")
datediff=28
for (( c=0; c<=$datediff; c++ ))
You can’t perform that action at this time.