Posts

Showing posts from July, 2020

sed, awk, grep

1. Print 1-6 range of lines with p cat demo.txt | sed -n '1, 6p' 2. Print Except  4,9 lines with d cat demo.txt | sed -n '6, 10d' 3. Print all non consecutive lines cat demo.txt | sed -n -e '6, 10p' -e '10, 13p' 3.replace string golbal cat demo.txt | sed "s/oldword/newword/g" Igonre character case cat demo.txt | sed "s/oldword/newword/gi" 4. Replace blank space cat demo.txt | sed -n 's/ */ /g' 5. Replace  in b/w 4,9 lines  cat demo.txt | sed -n '10,15 s/oldwrd/new/g' 6. Delete 4,9 lines with d cat demo.txt | sed -n '6, 10d' 7. Other 4,9 Delete another lines with d & n cat demo.txt | sed -n '6, 10!d' Example :1) Displaying partial text of a file With sed, we can view only some part of a file rather than seeing whole file. To see some lines of the file, use the following command, [linuxtechi@localhost ~]$ sed -n 22,29p testfile.txt here, option ‘n’ suppresses printing of whole file & option ‘p’ wi...

𝘴𝘤𝘳𝘪𝘱𝘵

#! /𝘣𝘪𝘯/𝘣𝘢𝘴𝘩 echo "`date '+%Y-%m-℅d %H:%M:%S.%N' ` - Ingestion - $1 - [INFO] - main begin" 𝘴𝘦𝘵 +𝘝𝘟 ####################### #check parameters #################### if [ $# -eq 0 ] then echo "`date '+%Y-%m-℅d %H:%M:%S.%N' ` - Ingestion - $1 - [Error] - no argument passed" echo "`date '+%Y-%m-℅d %H:%M:%S.%N' ` - Ingestion - $1 - [Error] - <arg1> ,<arg2>,<option>" exit 1 elif [ $# -gt 3 ] then echo "`date '+%Y-%m-℅d %H:%M:%S.%N' ` - Ingestion - $1 - [Error] - to many argument passed" echo "`date '+%Y-%m-℅d %H:%M:%S.%N' ` - Ingestion - $1 - [Error] - <arg1> ,<arg2>,<option>" exit 1  fi ###################### #compute the agrs, source name ##################### ENVARG=`echo "$1" | tr '[:upper:]' '[:lower:]' ` DEV=`echo "$2" | tr '[:upper:]' '[:lower:]' ` OptionVar=`echo "$3" | tr '[:upper:]...