Posts

Showing posts from June, 2018

Step-by-Step: Split a string in shell and get the last field

Image
Introduction String manipulation is a crucial skill in shell scripting. One common task is to split a string and retrieve specific fields, such as the last one. This can be useful for various purposes, such as parsing file paths, URLs, or command outputs. In this guide, we'll explore different methods to split a string and get the last field in shell scripting, starting from basic techniques and moving towards more advanced examples. How to split a string in shell and get the last field. in this tutorial, i written a small program use bash script split string /www/huu/phan/com/xyz to new path /www/huu/phan/com and last field of new path /www/huu/phan/com is com . How to Split a string in shell and get the last field Input: one_path is /www/huu/phan/com/xyz Output: new_path is  /www/huu/phan/com last_field of new_path is com My bash shell as below: #!/bin/bash ############### # # Author: HuuPV # My blog: www.huuphan.com # ############### # How to split a string in shel...

Lock and Unlock zimbra account from command line

Image
How to Lock and Unlock zimbra account from command line. some account sending email spam, you are administrator to need lock account from command line. To login your Mailbox system. To perform some command below to lock and unlock zimbra account. For example, I will lock and unlock account huupv02@mail.huuphan.com . The command line as below running su - zimbra . Now, let's start! Lock and Unlock zimbra account Step 1: Checking status account huupv02@mail.huuphan.com as below: $ zmprov ga huupv02mail.huuphan.com | grep zimbraAccountStatus The display as below: Another command to check status account with zmaccts as below: Step 2: To Lock zimbra account huupv02@mail.huuphan.com $ zmprov ma huupv02@mail.huuphan.com zimbraAccountStatus locked The display as picture below: To check account status after locked Step 3: To Unlock zimbra account huupv02@mail.huuphan.com $ zmprov ma huupv02@mail.huuphan.com zimbraAccountStatus active The display as picture belo...

Linux diff command

Image
In this tutorial, I use diff command output on screen. How to compare different line by line in  files. How to compare side by side, color , output do not output common lines with diff command. What diff command work? compare files line by line For example my topic, I compare line by line in 2 file: file1.txt and file2.txt The content file1.txt file [huupv@huupv huuphan.com]$ cat file1.txt <####################################> author: huupv My Blog: www.huuphan.com Hello everbody! <####################################> The content file2.txt file [huupv@huupv huuphan.com]$ cat file2.txt <####################################> author: huupv My Blog: www.devopsrole.com Hello everbody! <####################################> The default compare line by line with diff comand [huupv@huupv huuphan.com]$ diff file1.txt file2.txt The output as below: 3c3 < My Blog: www.huuphan.com --- > My Blog: www.devopsrole.com The output nu...