Posts

Showing posts with the label cmd

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 

Linux command line

https://findwords.info/term/uname 1. uname -m Uname uname (short for unix name) is a computer program in Unix and Unix-like computer operating systems that prints the name, version and other details about the current machine and the operating system running on it. The uname system call and command appeared for the first time in PWB/UNIX. Both are specified by POSIX. 2. Check running service in Linux for example check docker.service //Run this command on Linux systems not using Systemd $ service docker status docker start/running, process 29393 //Run this command on Linux systems that are using Systemd $ systemctl is-active docker active