Created
March 9, 2024 08:39
-
-
Save Xeophon/424ef9c174e725994676613e31571aa7 to your computer and use it in GitHub Desktop.
Polars Docs Concat
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Set the GitHub repository URL and branch | |
repo_url="https://github.com/pola-rs/polars.git" | |
branch="main" | |
# Set the paths of the folders to fetch | |
folder1="docs/src/python/user-guide" | |
folder2="docs/user-guide" | |
# Set the output file name | |
output_file="polars_docs.md" | |
# Get the current directory where the script is executed | |
current_dir=$(pwd) | |
# Create a temporary directory | |
temp_dir=$(mktemp -d) | |
echo "Created temporary directory: $temp_dir" | |
# Clone the repository and checkout the specified branch | |
echo "Cloning repository: $repo_url" | |
git clone --depth 1 --branch $branch $repo_url $temp_dir | |
if [ $? -ne 0 ]; then | |
echo "Failed to clone the repository. Please check the repository URL and branch." | |
exit 1 | |
fi | |
# Change to the temporary directory | |
cd $temp_dir | |
echo "Changed to temporary directory: $(pwd)" | |
# Find and concatenate all .py and .md files from the specified folders and their subfolders | |
echo "Concatenating files..." | |
find $folder1 $folder2 -type f \( -name "*.py" -o -name "*.md" \) -exec cat {} + > $output_file | |
if [ $? -ne 0 ]; then | |
echo "Failed to concatenate files. Please check the folder paths and file permissions." | |
exit 1 | |
fi | |
# Move the output file to the directory where the script is executed | |
mv $output_file "$current_dir/" | |
echo "Moved output file to: $current_dir/$output_file" | |
# Change back to the original directory | |
cd "$current_dir" | |
echo "Changed back to original directory: $(pwd)" | |
# Remove the temporary directory | |
rm -rf $temp_dir | |
echo "Removed temporary directory: $temp_dir" | |
echo "Concatenation complete. Output file: $output_file" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment