Skip to content
TheChatArchiveThe Chat Archive
gpt-3.5-turbo-0125· OpenAIAi2 WildChat-4.8M (AI2)

I need a bash script for looping over *.csv files for each file check the content of…

  1. User

    I need a bash script for looping over *.csv files

    for each file check the content of each file if ‘(’ or ‘)’ exits then print the file name

  2. Assistant

    Here is a bash script that will loop over all *.csv files in the current directory and check for the existence of '(' or ')' in each file:

    #!/bin/bash
    
    # Loop over all *.csv files in the current directory
    for file in *.csv; do
        # Check if the file contains '(' or ')' using grep
        if grep -q "[(|)]" "$file"; then
            # Print the file name if '(' or ')' exists
            echo "$file"
        fi
    done
    

    You can save this script to a file (e.g., check_csv_files.sh), make it executable with chmod +x check_csv_files.sh, and then run it to check the contents of each *.csv file in the current directory.