Advertisement
Markort

bash script to link golang tools to bin folder

Feb 13th, 2025
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.64 KB | Source Code | 0 0
  1. #!/bin/bash
  2.  
  3. # Define source and target directories
  4. SRC_DIR="/home/markort/.go/bin"
  5. DEST_DIR="/home/markort/bin"
  6.  
  7. # Ensure the destination directory exists
  8. mkdir -p "$DEST_DIR"
  9.  
  10. # Loop over all files in the source directory
  11. for file in "$SRC_DIR"/*; do
  12.     # Get the base filename
  13.     filename=$(basename "$file")
  14.  
  15.     # Define the symlink name with "go_" prefix
  16.     symlink_name="go-$filename"
  17.  
  18.     # Create the symlink in the destination directory
  19.     ln -sf "$file" "$DEST_DIR/$symlink_name"
  20.  
  21.     # Print confirmation
  22.     echo "Symlink created: $DEST_DIR/$symlink_name -> $file"
  23. done
  24.  
  25. echo "All symlinks created successfully."
  26.  
  27.  
Tags: BASH go
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement