KJH File Exchange Center

KJH 파일 공유 센터

EDT       UTC       KST

GCC Compile

gcc -o abcd abc.c

Bash Commandline Edit

※Written in CentOS 8

Bash shell is one of the basic shell in UNIX system, especially Linux OS

Because it uses the readline library, users can use shortcut keys on commandline in a terminal.

But one of them can be crashed with a GUI application such as PuTTY, XShell, etc.


Moving Cursor

- Ctrl + A / Ctrl + E: Move the first/last position of a line which the cursor exists

- Ctrl + F / Ctrl + B: Move to the left/right by a letter

- Alt + F / Alt + B: Move to the left/right by a word

- Ctrl + P / Ctrl + N: Move to the command history(up/down)

- Ctrl + L: clear and move to the most left position


Text editing

- Ctrl + D: Delete a current letter

- Ctrl + K: Delete a line from a current position to the right

- Ctrl + U: Delete a line from a current position to the left

- Alt + D: Delete a word from a current position to the right

- alt + Backspace: Delete a word from a current position to the left

- Ctrl + Y: Insert a cut text

How to change a specified word in a specified files?

grep -Rl "target_strings" "filename" | xargs sed -i 's/target_strings/changed_strings/g'

R = apply changes to this folder, subfolders and files

l = print file names only


Example

grep -Rl "_moon" plotsc* | xargs sed -i 's/_moon/_3body/g'

grep -Rl output31\{2\} plotsc* | xargs sed -i s/output31\{2\}/output31\{3\}/g

grep -Rl output31\{5\} plotsc* | xargs sed -i s/output31\{5\}/output31\{6\}/g

grep -Rl close plotsc* | xargs sed -i 's/close/\% close/g'

grep -Rl rv2hvhat * | xargs sed -i s/rv2hvhat/rv2hvhat/g

How to change a color of font or background of PuTTY terminal?

PuTTY Configuration - Colours

C/TC Shell Script Example


The First line meaning: execute the script as input to the program listed after the #! characters.

-f flag meaning: tell tcsh not to execute .cshrc when it starts up - so this makes script execution speed up


#!/bin/tcsh -f


set output

set month_std = 1

set year_std = $3

set month = $1

set day = $2

set year = $3


if ( ( $year % 4 ) == 0 ) then

   set array_m = (31 29 31 30 31 30 31 31 30 31 30 31)

else

   set array_m = (31 28 31 30 31 30 31 31 30 31 30 31)

endif

set sum_N_m = 0

set i = 1


while( $i <= ($month - $month_std) )

   @ sum_N_m += $array_m[$i]

   @ i++

end


@ solution = $sum_N_m + $day


echo $solution

exit 0