Posts

Showing posts from December, 2021

tr command line tutorial

 https://www.tecmint.com/tr-command-examples-in-linux/ tr means translate It will walk through all the characters in the text and can translate a character or a phrase into a new character or a new phrase. For example: nguyenhuybo@VN-LV00184-N ~ % echo "Hello my love" | tr "[:lower:]" "[:upper:]" HELLO MY LOVE nguyenhuybo@VN-LV00184-N ~ % echo "{**} <3 me"| tr "{}" '[]' [**] <3 me nguyenhuybo@VN-LV00184-N ~ % echo I am sorry| tr "[:space:]" "\t" I am sorry %    

Multi stage builder with gradle

FROM  gradle:jdk11  AS  cache WORKDIR / app ENV GRADLE_USER_HOME / cache COPY build.gradle gradle.properties settings.gradle . / RUN gradle -- no-daemon build -- stacktrace FROM gradle:jdk11 AS builder WORKDIR / app COPY -- from= cache / cache / home / gradle / .gradle COPY . / app / RUN gradle -- no-daemon build -- stacktrace FROM harbor.hub.com / -project / openjdk: 11.0.12 - jre-slim RUN apt-get install - y tzdata # timezone env with default ENV TZ Asia / Tokyo RUN ln - snf / usr / share / zoneinfo / $ TZ / etc / localtime && echo $ TZ > / etc / timezone #COPY ./app/iims/build/libs/iims-1.0-SNAPSHOT.jar /app/ COPY -- from= builder / app / app / iims / build / libs / xxx-1 .0 - SNAPSHOT.jar / app / WORKDIR / app ENTRYPOINT [ "java" , "-jar" , "xxx-1.0-SNAPSHOT.jar" ]

Best application for MACOS

 https://starship.rs/ https://www.raycast.com/ https://superuser.com/questions/400360/syntax-highlighting-in-terminal-mac-os-x

shell script demo

  nguyenhuybo@VN-LV00184-N Downloads % cat call_api.sh   #!/bin/bash n=$1 echo $2 send_omikuji(){     echo "starting new call api: omikuji"     curl -X 'POST' 'https://talkfortune-notification-hook.line-apps-beta.com/callback' -H 'connection: close' -H 'user-agent: LineBotWebhook/2.0' -H 'content-length: 315' -H 'content-type: application/json; charset=utf-8' -H 'x-line-signature: plpngha8sEj7LJe6xd/6InfKBWQ32kso2SOaAQKL01o=' -H 'host: talkfortune-notification-hook.line-apps-beta.com' -d $'{"destination":"u367dfc1ff8ed00c67a5966f542e5c25e","events":[{"type":"message","message":{"type":"text","id":"379186645792718849","text":"おみくじ"},"timestamp":1638844157276,"source":{"type":"user","userId":"uf4167f77e339b332dd154eb8ead96191"},"...

cut command line

 https://www.geeksforgeeks.org/cut-command-linux-examples/?ref=lbp

tr command line

  1. How to convert lower case to upper case To convert from lower case to upper case the predefined sets in tr can be used. $cat greekfile Output: WELCOME TO GeeksforGeeks $cat greekfile | tr “[a-z]” “[A-Z]” Output: WELCOME TO GEEKSFORGEEKS or $cat geekfile | tr “[:lower:]” “[:upper:]” Output: WELCOME TO GEEKSFORGEEKS 2. How to translate white-space to tabs The following command will translate all the white-space to tabs $ echo "Welcome To GeeksforGeeks" | tr [:space:] '\t' Output: Welcome To GeeksforGeeks 3. How to translate braces into parenthesis You can also translate from and to a file. In this example we will translate braces in a file with parenthesis. $cat greekfile Output: {WELCOME TO} GeeksforGeeks $ tr '{}' '()' newfile.txt Output: (WELCOME TO) GeeksforGeeks

jobs, kill

  23. jobs command jobs  command will display all current jobs along with their statuses. A job is basically a process that is started by the shell. 24. kill command

locate, find, and grep

  11. locate command You can use this command to  locate  a file, just like the search command in Windows. What’s more, using the  -i  argument along with this command will make it case-insensitive, so you can search for a file even if you don’t remember its exact name. To search for a file that contains two or more words, use an asterisk  (*) . For example,  locate -i school*note  command will search for any file that contains the word “school” and “note”, whether it is uppercase or lowercase. 12. find command Similar to the  locate  command, using  find  also searches for files and directories. The difference is, you use the  find  command to locate files within a given directory. As an example, find  /home/ -name notes.txt  command will search for a file called  notes.txt  within the home directory and its subdirectories. Other variations when using the  find  are: To find files in the...

awk

  $ awk –F'[ :\t]' '{print $1, $2, $3}' people.txt ---------------------------- $ awk '{print NR, $1, $2, $4}' people.txt The output will be: 1 Bill Thomas 08/9/1968 2 Fred Martin 22/7/1982 3 Julie Moore 25/2/1978 4 Marie Jones 05/8/1972 5 Tom Walker 14/1/1977 ---------------------------- $ cat people.txt | awk '$3 > 6500 {print $1, $2}' ------------- Bill Thomas 8000 08/9/1968 Fred Martin 6500 22/7/1982 Julie Moore 4500 25/2/1978 Marie Jones 6000 05/8/1972 Tom Walker 7000 14/1/1977 $ awk '{ if ($3 > 7000) { print "person with salary more than 7000 is \n", $1, " " , $2;} }' people.txt The output is as follows: person with salary more than 7000 is Bill Thomas =========================== An example of the awk command with the for loop is as follows: $ awk '{ for( i = 1; i <= NF; i++) print NF, $i }' people.txt...

Command line arguments

  $0 Shell script name or command $1–$9 Positional parameters 1–9 ${10} Positional parameter 10 $# Total number of parameters $* Evaluates to all the positional parameters $@ Same as $*, except when double quoted "$*" Displays all parameters as "$1 $2 $3", and so on "$@" Displays all parameters as "$1" "$2" "$3", and so on