Skip to main content

Posts

Move selected files in Linux

Recent posts

vim or vi searching for whole words or string

Search for a whole word or string in VI or VIM, can be done easily and a time savee so no need to keep pressing next or 'n' for the next match. How to search for a whole word or string in VI or VIM? Example open a file with a list of IP addresses. vim list-of-local-ips.txt Example contents: 192.168.13.130 192.168.13.131 192.168.13.1 192.168.13.135 192.168.13.137 192.168.13.23 192.168.13.13 192.168.13.100 If vi or vim is insert mode, press ESC until it's in command mode, If need to search for 192.168.13.1, or just 13.1 In comand-line mode type:  :/\<13.1\> and press enter  Or see picture below: After pressing enter it will go directly to 192.168.13.1,  if /13.1 is type then it will match also 192.168.13.135, 192.168.13.131 etc.. But with the /\<word or string\> syntax it will find the whole word. That's it, explore vi/vim for time saver tips. Cheers! Lift up your needs in Prayer; with a humble and contrite heart. God listens to the broken hearted....

Add SSH keys to known-hosts in Linux

Setting up a new environment of Linux boxes either Physical servers, VMs or Containers, one thing to consider is how you will login or manage those devices. In Linux world, SSH is the most common way to manage headless servers or VMs. SSH keys must be added to ~/.ssh/known_hosts to preload to the host keys before connecting to the new servers. There quite a few ways to do it, via bash script, or simply logging in and copying manually the key.but quite tedious and not the practical way if there are hundreds of more servers. ssh-keyscan server1 server2 server3 >> ~/.ssh/known_hosts This will suppress the question whether you want to add the keys or not, and type yes to continue. ssh-keyscan won't require any manual intervention once the connectivity is established it will just add all the keys available on the remote servers to known_hosts. Yes rather than typing ssh-keyscan server1 server2 it would be better to have a list on a text file and use while loop to read the file and...

Linux Bash rename multiple files

Bash script/command below shows how to rename multiple files. If the filename shows some pattern, then it will be easier to rename.  Example filename: file_text_a.txt file_text_b.txt file_text_c.txt file_text_etc... ... .txt Script/command below, shows some magic to rename files all at once. The command below can be integrated to a script or simply run the command on the terminal. Create some dummy files for testing before running on actual files to be renamed or in production. find . -name "*.txt" -exec sh -c '   for file; do       newf=$(echo "$file" | sed "s/text/tested/" )  &&   mv "$file" "$newf"   done ' sh {} + Output is: file_tested_a.txt file_tested_b.txt Since the command uses sed, replace 'text' with any string to be searches and replace 'tested' also with any new string for the filename. Till next time.. Enjoy Linux and scripting... Put your trust in God and have Faith. Exodus 14:14, "The...

Systemd *-ctl commands to manage Linux system

Systemd ecosystem provides tools to manage the Linux system. Here are some quick commands to check Linux system status. systemctl -  manage system services and units timedatctl - check system time, date and NTP localectl - quickly check system locale, language, kb layout hostnamectl - check static hostname, OS, kernel, architecture x86 or x64 resolvectl - quickly check DNS IP networkctl - quickly check interfaces names, operational status of interfaces, and setup whether managed or unmanaged loginctl - check session if, username, and for how long the user is logged in journalctl - to check services logs why some services are not starting  Those are the basic and most common ones. Enjoy Linux-ing. Keep the Faith alive, Trust Jesus! God bless!

Android Studio view XML code layout

View XML code in Android Studio. By default, in Android Studio Narwhal | 2025.1.1 Patch 1 what is shown is the layout of the XML. Android Studio, provides 3 options for previewing the XML. 1 - View by code Only 2 - View with XML code and the output or the layout 3 - View only the output of the XML or view the design only To select these options once an XML or layout file is opened. The options can be found on the top right of the screen, just beside the current XML file that os being viewed. See this screenshot below on how it looks like: Hope it helps. Life is a gift. Life is a journey. Trust the Almighty, Pray always.

Find duplicate or unique values in a column using Excel formula

Finding duplicate values in Excel can easily be done using Excel Formula. Manually find duplicate values in a single column with 100 or more rows is tedious and prone to errors. Thankfully, Excel formula can do this task with precision. Assuming, the data or values has no trailing white spaces. Trailing white spaces, will cause problem because even though its whitespace still treated as a character by Excel. Data must be sanitized before comparing. Excel fomula to find Unique values or duplicates can be done using the formula below. =IF(COUNTIF($A$1:$A$13,A1)>1, "Duplicate","Unique") $A$1:$A$13 ==> Range to check duplicate or unique values, adjust the range as required A1 ==> Check duplicate values at this row or start comparing at A1 >1 ==> If there is a duplicate or a similar value more than 1, if the value is 2. Then the 3rd value that is similar to the other two will be identified as duplicate "Duplicate","Unique...

AWS view instance store volume - ephemeral storage

Instance store volume in AWS is not like the EBS Volume (ebs - elastic block storage). The main difference between EBS and instance store volume, is EBS data or its contents will persist after reboot or shutdown. And for EBS volume you can take snapshot, create image do a backup or simply attached the EBS volume to another instance. Where as for instance store volume, which is physically attached to the host. It can't be search or can't be found on the "Volume" navigation pane. Thus, snapshot or taking backup is not possible. Instance store volume is some sort of a RAMDisk, in which it is indeed process data quite fast. However, if the instance is rebooted or shutdown all data is gone. Ideal only for dynamic data processing, that once data is process on the fly; data can be discarded or not needed anymore. How to view or check whether the instance you have got instance store volume? In a Linux instance, type the command below on a Terminal window: lsblk -o +...