Advertisement
Guest User

Untitled

a guest
Mar 25th, 2019
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.51 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. if [ "$#" -ne 2 ]; then
  4.     echo "Usage: ./script.sh <directory 1> <directory 2>"
  5.     exit 1
  6. fi
  7.  
  8. if [ ! -d $1 ] || [ ! -d $2 ]; then
  9.     echo "At least one of the arguments given is not a directory."
  10.     exit 1
  11. fi
  12.  
  13. destination=$1
  14. source=$2
  15.  
  16. for file in $(ls $source); do
  17.     # jesli plik nie jest katalogiem ani symlinkiem
  18.     if [ ! -d $source/$file ] && [ ! -L $source/$file ]; then
  19.         ln $(realpath "$source/$file") $destination/$file # link w postaci kanonicznej
  20.     fi
  21. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement