|
| 1 | +{ |
| 2 | + "language": "code_bash", |
| 3 | + "groups": [ |
| 4 | + [0, 100], |
| 5 | + [101, 300], |
| 6 | + [301, 600], |
| 7 | + [601, 9999] |
| 8 | + ], |
| 9 | + "quotes": [ |
| 10 | + { |
| 11 | + "text": "echo \"Hello, World!\"", |
| 12 | + "source": "Basic Hello World in Bash", |
| 13 | + "length": 20, |
| 14 | + "id": 1 |
| 15 | + }, |
| 16 | + { |
| 17 | + "text": "#!/bin/bash\n\n# This script prints numbers from 1 to 10\nfor i in {1..10}\ndo\n echo $i\ndone", |
| 18 | + "source": "Looping through numbers in Bash", |
| 19 | + "length": 89, |
| 20 | + "id": 2 |
| 21 | + }, |
| 22 | + { |
| 23 | + "text": "#!/bin/bash\n\n# Check if a file exists\nFILE=\"/path/to/file.txt\"\nif [ -f \"$FILE\" ]; then\n echo \"$FILE exists.\"\nelse\n echo \"$FILE does not exist.\"\nfi", |
| 24 | + "source": "File existence check in Bash", |
| 25 | + "length": 148, |
| 26 | + "id": 3 |
| 27 | + }, |
| 28 | + { |
| 29 | + "text": "#!/bin/bash\n\n# Read user input\necho \"Enter your name:\"\nread NAME\necho \"Hello, $NAME!\"", |
| 30 | + "source": "Reading user input in Bash", |
| 31 | + "length": 85, |
| 32 | + "id": 4 |
| 33 | + }, |
| 34 | + { |
| 35 | + "text": "#!/bin/bash\n\n# Function to greet a user\ngreet() {\n echo \"Hello, $1!\"\n}\n\ngreet \"Alice\"", |
| 36 | + "source": "Defining and using functions in Bash", |
| 37 | + "length": 86, |
| 38 | + "id": 5 |
| 39 | + }, |
| 40 | + { |
| 41 | + "text": "#!/bin/bash\n\n# Using command line arguments\necho \"Script name: $0\"\necho \"First argument: $1\"\necho \"Second argument: $2\"", |
| 42 | + "source": "Using command line arguments in Bash", |
| 43 | + "length": 119, |
| 44 | + "id": 6 |
| 45 | + }, |
| 46 | + { |
| 47 | + "text": "#!/bin/bash\n\n# Simple case statement\necho \"Enter a number between 1 and 3:\"\nread NUM\ncase $NUM in\n 1)\n echo \"You entered one.\" ;;\n 2)\n echo \"You entered two.\" ;;\n 3)\n echo \"You entered three.\" ;;\n *)\n echo \"Invalid input.\" ;;\nesac", |
| 48 | + "source": "Using case statements in Bash", |
| 49 | + "length": 246, |
| 50 | + "id": 7 |
| 51 | + }, |
| 52 | + { |
| 53 | + "text": "#!/bin/bash\n\n# Create a new directory\nNEW_DIR=\"/path/to/new_directory\"\nmkdir -p \"$NEW_DIR\"\necho \"Directory $NEW_DIR created successfully.\"", |
| 54 | + "source": "Creating a new directory in Bash", |
| 55 | + "length": 138, |
| 56 | + "id": 8 |
| 57 | + }, |
| 58 | + { |
| 59 | + "text": "#!/bin/bash\n\n# Backup a directory\nSOURCE_DIR=\"/path/to/source\"\nBACKUP_DIR=\"/path/to/backup\"\ntar -czf \"$BACKUP_DIR/backup_$(date +%F).tar.gz\" -C \"$SOURCE_DIR\" .", |
| 60 | + "source": "Backing up a directory in Bash", |
| 61 | + "length": 159, |
| 62 | + "id": 9 |
| 63 | + }, |
| 64 | + { |
| 65 | + "text": "#!/bin/bash\n\n# Monitor disk usage\ndf -h | grep '^/dev/' | while read line; do\n USAGE=$(echo $line | awk '{print $5}' | sed 's/%//')\n if [ $USAGE -gt 80 ]; then\n echo \"Warning: Disk usage is at ${USAGE}%\"\n fi\ndone", |
| 66 | + "source": "Monitoring disk usage in Bash", |
| 67 | + "length": 218, |
| 68 | + "id": 10 |
| 69 | + } |
| 70 | + ] |
| 71 | +} |
0 commit comments