That's normal. cd - prints the directory name. If it goes nowhere, you haven't used cd before. Use cd $OLDPWD explicitly.
The prev keyword suggests you want to return to where you came from after inspecting land.
Save this as backup_land.sh:
#!/bin/bash # Backup script: filedot + ls + prev + rar newSOURCE_DIR="land" BACKUP_NAME="land_backup_$(date +%Y%m%d_%H%M%S).rar" filedot to ls land 8 prev rar new
if [ ! -d "$SOURCE_DIR" ]; then echo "Error: $SOURCE_DIR not found." exit 1 fi
echo "Entering $SOURCE_DIR..." cd "$SOURCE_DIR"
echo "Listing all files (including dotfiles):" ls -lah That's normal
echo "Returning to previous directory..." cd -
echo "Creating new RAR version 8 archive: $BACKUP_NAME" rar a -ma5 -md512m -m5 -r "$BACKUP_NAME" "$SOURCE_DIR"
if [ $? -eq 0 ]; then echo "Backup completed: $(realpath $BACKUP_NAME)" else echo "RAR creation failed." fiRun it: chmod +x backup_land
Run it:
chmod +x backup_land.sh
./backup_land.sh
Update RAR: Visit rarlab.com for rar version 6.20+ which supports RAR 5/6/7/8. Version 7.00 introduced RAR 7, version 7.10 added RAR 8 preview.
Check version:
rar -v
# Look for "RAR 7.10" or higher.