~james/gengo

gengo/samples-test/samples/Shell/rename.sh -rw-r--r-- 422 bytes
50871857 — james chore(import): snapshot james.dad.town/gengo at 8f775550b0ee 16 hours ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/bin/sh

# Check if correct number of arguments is provided
if [ $# -ne 2 ]; then
    echo "Usage: $0 old_filename new_filename"
    exit 1
fi

# Check if the source file exists
if [ ! -f "$1" ]; then
    echo "Error: File '$1' does not exist"
    exit 1
fi

# Rename the file
mv "$1" "$2"

if [ $? -eq 0 ]; then
    echo "File successfully renamed from '$1' to '$2'"
else
    echo "Error: Failed to rename the file"
fi