Bash Shell: Extract Digits From a String

If you want to extract digits from a string in bash, you can use the following methods: Using grep: string=”abc123def456″ digits=$(echo $string | grep -o ‘[0-9]\+’) echo $digits Output: 123456 Using sed: string=”abc123def456″ digits=$(echo $string | sed ‘s/[^0-9]*//g’) echo $digits Output: 123456 Using awk: string=”abc123def456″ digits=$(echo $string | awk ‘/[0-9]+/{ gsub(/[^0-9]+/, “”, $0); print $0 … Read more

Debian / Ubuntu Linux Disable / Remove All NFS Services

To disable or remove all NFS services on Debian/Ubuntu Linux, you can use the following steps: Stop the NFS server service: sudo service nfs-kernel-server stop Disable the NFS server service from starting automatically during boot: sudo update-rc.d nfs-kernel-server disable Uninstall the NFS server packages: sudo apt-get remove nfs-kernel-server Repeat the above steps for any other … Read more

Perl Command To List Installed CPAN Modules

To list the installed CPAN modules in Perl, you can use the following command: perl -MCPAN -e ‘my $c = CPAN::Shell->expand(“Module”, “/./”); print join “\n”, map { $_->id } sort { $a->id cmp $b->id } $c;’ This will list all the installed CPAN modules in alphabetical order. To search for a specific module, you can … Read more

FreeBSD Install VMWare Guest Tools

Installing VMware Guest Tools in a FreeBSD virtual machine involves the following steps: Download the appropriate VMware tools for your version of FreeBSD. Extract the tools archive to a directory of your choice. Open a terminal window in the directory where you extracted the tools. Mount the virtual machine’s disk image using the following command: … Read more

FreeBSD: The search target requires INDEX-9. Please run make index or make fetchindex

The “The search target requires INDEX-9. Please run make index or make fetchindex” error message in FreeBSD indicates that the necessary index for the ports collection is missing. This error occurs when you run a command such as “portmaster” or “portupgrade” without the necessary index. To resolve this error, run the following command as the … Read more