Yeah AI is really stupid especially when it comes to bash. Once one of my colleague came to me asking a bash script not working that they got from ChatGPT. It was 20-30 lines with function and everything was a variable even the commands. I didn’t even bother reading, asked them what they were trying to do and wrote a simple one liner and it did exactly what they wanted in first try…
I’ve had pretty good success with DeepSeek making decent bash scripts. What was the script out of curiosity, I can try and see what DeepSeek spits out.
here’s what DeepSeek gave me for the following prompt: write a small bash script to check if a CSV exists and if it does rename to the filename_date.CSV and upload to hdfs, keep it simple
#!/bin/bash# Check if filename argument is providedif [ $# -eq 0 ]; thenecho"Usage: $0 <csv_filename>"exit 1
fi
CSV_FILE="$1"# Check if file existsif [ ! -f "$CSV_FILE" ]; thenecho"Error: File $CSV_FILE not found!"exit 1
fi# Generate new filename with date (YYYYMMDD format)
DATE=$(date +%Y%m%d)
NEW_FILENAME="${CSV_FILE%.*}_${DATE}.csv"# Rename the filemv"$CSV_FILE""$NEW_FILENAME"# Upload to HDFS
hdfs dfs -put "$NEW_FILENAME" /path/to/hdfs/directory/
echo"Successfully processed: $NEW_FILENAME"
OK at least it didn’t create functions for everything. ChatGPT had a function to kinit, to rename and to upload to hdfs. And each function had 2-3 line comments. I mean for a single command how can you put 3 lines of comments.
Yeah AI is really stupid especially when it comes to bash. Once one of my colleague came to me asking a bash script not working that they got from ChatGPT. It was 20-30 lines with function and everything was a variable even the commands. I didn’t even bother reading, asked them what they were trying to do and wrote a simple one liner and it did exactly what they wanted in first try…
I’ve had pretty good success with DeepSeek making decent bash scripts. What was the script out of curiosity, I can try and see what DeepSeek spits out.
Check if a CSV exists and if it does rename to the filename_date.CSV and upload to hdfs
here’s what DeepSeek gave me for the following prompt: write a small bash script to check if a CSV exists and if it does rename to the filename_date.CSV and upload to hdfs, keep it simple
#!/bin/bash # Check if filename argument is provided if [ $# -eq 0 ]; then echo "Usage: $0 <csv_filename>" exit 1 fi CSV_FILE="$1" # Check if file exists if [ ! -f "$CSV_FILE" ]; then echo "Error: File $CSV_FILE not found!" exit 1 fi # Generate new filename with date (YYYYMMDD format) DATE=$(date +%Y%m%d) NEW_FILENAME="${CSV_FILE%.*}_${DATE}.csv" # Rename the file mv "$CSV_FILE" "$NEW_FILENAME" # Upload to HDFS hdfs dfs -put "$NEW_FILENAME" /path/to/hdfs/directory/ echo "Successfully processed: $NEW_FILENAME"
OK at least it didn’t create functions for everything. ChatGPT had a function to kinit, to rename and to upload to hdfs. And each function had 2-3 line comments. I mean for a single command how can you put 3 lines of comments.
I’ve never touched ChatGPT out of principle, but everything I hear about it makes it sound like hot garbage.