Welcome
My name is Ulysses. Sr. Cloud Engineer at Cardinal Health.
About This Website
This is my static site based on Hugo.
My name is Ulysses. Sr. Cloud Engineer at Cardinal Health.
This is my static site based on Hugo.
These are the steps taken to make my Logitech K811 keyboard to connect via Bluetooth in Linux Mint. Run bluetoothctl bluetoothctl In the bluetoothctl command line run these commands. Replace with your own device number. remove 00:XX:XX:XX:XX:1F scan on pair 00:XX:XX:XX:XX:1F connect 00:XX:XX:XX:XX:1F trust 00:XX:XX:XX:XX:1F You may be asked to type a six digit code to pair the device.
How to split a file into multiple files. In this example, it’s split in lines of 100. #!/bin/bash # Input file name input_file="$1" # Lines per file lines_per_file=100 # Check if input file exists if [ ! -f "$input_file" ]; then echo "Error: Input file '$input_file' not found." exit 1 fi # Get the number of lines in the input file total_lines=$(wc -l < "$input_file") # Calculate the number of output files needed num_files=$(( (total_lines + lines_per_file - 1) / lines_per_file )) # Loop through the input file and split it into multiple files for ((i=1; i<=num_files; i++)); do # Output file name output_file="${input_file}_part${i}" # Extract lines from the input file head -n "$((i * lines_per_file))" "$input_file" | tail -n "$lines_per_file" > "$output_file" done echo "File '$input_file' split into $num_files files." exit 0
How to copy files from source to the target directory. Copy only if file is not present in the target. #!/bin/bash source="/home/ulysses/Cameras/fujifilm" target="/home/ulysses/Cameras/Fujifilm" output="output.txt" > $output # Check if source directory exists if [ ! -d "$source" ]; then echo "Error: Directory '$source' does not exist." exit 1 fi # Find all JPG files in the source directory find "$source" -type f -iname "*.JPG" | while read -r file; do # Get the basename. filename=$(basename "$file") # Check if filename is in target directory. if find "$target" -type f -name "$filename" -print -quit | grep -q .; then true else # Copy file from source to target. cp $source/$filename $target/100_FUJI/ echo "Copying $file to $target/100_FUJI." | tee -a $output fi done
Tar multiple directories to a single tar.gz file. tar -czvf /home/ulysses/Code/backup.tar.gz ~/Documents/ ~/Downloads ~/Git/gcloud/ ~/Pictures ~/Videos To list files inside the tar.gz file, run this. tar -tzvf /home/ulysses/Code/backup.tar.gz
Here’s the gcloud command to create a new image with an extended license with an option to add family type. gcloud beta compute images create new-image-with-license \ --source-image=this-is-the-source-image \ --family rocky-9 \ --project your-project-id \ --user-licenses=https://www.googleapis.com/compute/v1/projects/rhel-cloud/global/licenses/rhel-7-els Any VM provisioned using this image will now have the extended license.
Here’s a gsutil command to copy a directory recursively to a GCS bucket via parallel uploads. # Define source and destination SOURCE_DIR="/path/to/local/directory" DEST_BUCKET="gs://your-bucket-name" # Use gsutil with the -m flag for parallel uploads gsutil -m cp -r "$SOURCE_DIR" "$DEST_BUCKET"
I fixed my Bluetooth issues with my Logitech K811 keyboard on Linux Mint Take note of your device ID in a similar format as a MAC Address. Here are the steps I took to fix the pairing issue. Run bluetoothctl, you will get a special prompt. bluetoothctl Perform a scan. Copy the device ID. scan on Remove the device. remove ID Finally reconnect device. connect ID trust ID pair ID You may be prompted to enter the pairing code. ...
I have a Python script that copies files from a local directory to a GCS bucket and down a couple of directories. The script was tested in a Python virtual environment. Google Cloud Storage module is required which can be installed via pip. pip install google-cloud-storage If you have trouble running pip, you may have to run this on Linux Mint (Ubuntu) to update the virtual environment. apt install python3.12-venv For authentication, you will need to download the service account credentials key that has write access to the GCS bucket. ...
Here’s the code for a bash script that generates another bash script and then executes it, as well as deletes it in the end. #!/bin/bash # Define the script content script_content='#!/bin/bash echo "Hello, this is the generated script!" echo "The current date and time is: $(date)" ' # Define the name of the new script new_script="generated_script.sh" # Write the content to the new script file echo "$script_content" > "$new_script" # Make the new script executable chmod +x "$new_script" # Execute the new script ./"$new_script" rm -f $new_script
How to convert uppercase to lowercase and vice versa. upper_project=$(echo "$project" | tr '[:lower:]' '[:upper:]') Vice versa lower_project=$(echo "$project" | tr '[:upper:]' '[:lower:]') Display output echo $upper_project echo $lower_project