Memo for Some Linux Commands

 mkdir -p

With the help of mkdir -p command you can create sub-directories of a directory. It will create parent directory first, if it doesn't exist. But if it already exists, then it will not print an error message and will move further to create sub-directories.

 

tee

reads the standard input and writes it to both the standard output and one or more files.

cat file1

geek

for

geeks

cat file2

geek

for

geeks

wc -l file1 | tee -a file2

cat file2

geek

for

geeks

3 file1

 

 

sed

is a powerful text stream editor. Can do insertion, deletion, search and replace.

 

awk

is a scripting language used for manipulating data and generating reports. 


'>' vs '>>'

> will override and >> will append.


#!/bin/bash

#kill client java process

echo "kill service process ..."

PIDS=$(ps -ef | grep java | awk '{print $2}')

echo "killing the ($PIDS)"

kill -9 $PIDS




It's also commonly use systemd and journalctl to manage service in linux.

ls -ltr

ps -auxfww

Comments