Posts

Showing posts from January, 2019

Bash basics for personal use

Replace using sed when too many slashes are there. --------------------------------------------------- sed -i -e 's@/home/username/jas/@/home/username/jas/folder/@g' file.sh sed -i -e 's@xxx.xxx.xxx.xxx@xxx.xxx.xxx.xxx@g' file.sh Note : In bash scripting on remote server ssh login, we could experience problems with awk print $ and "`". In such situations, use cut and there will be no such issues. To add double quotes in a line which has words separated by comma. ----------------------------------------------------------------- sed -e 's/"//g' -e 's/[^,]*/"&"/g' -i filename To add double quotes at end of line in a file. ------------------------------------------------- sed -e 's/$/"/' -i filename To add double quotes at beginning of a line in a file. ----------------------------------------------------- sed -e 's/^/"/' -i filename To check a log file between two dates. -------------------------------