write a bash script to look for these two lines in a directory of .sql files :
"sis\_source\_id" character varying(255),
CONSTRAINT "pk\_accounts" PRIMARY KEY ("id")

and then insert the folowing line:
"ts" timestamp without time zone NOT NULL,
user
Sure, here's a basic Bash script that searches for the two lines in .sql files in a directory and inserts the new line:

```bash
#!/bin/bash

# Directory to search for .sql files
dir="/path/to/directory"

# Array of lines to search for
lines=( "sis_source_id" "CONSTRAINT \"pk_accounts\" PRIMARY KEY (\"id\")" )

# Line to insert
new_line="\"ts\" TIMESTAMP WITHOUT TIME ZONE NOT NULL,"

# Loop througheach file and replace the specified lines
find "$dir" -type f -name "*.sql" -print0 | xargs -0 sed -i 's/'"${lines[0]}'"/'"${new_line}"'/g'
find "$dir" -type f -name "*.sql" -print0 | xargs -0 sed -i 's/'"${lines[1]}'"/\n'"${new_line}""'/g'
```

This script uses `find` to look for all .sql files in the directory, and then uses `sed` to replace the specified lines with the new line. Note that `sed -i` uses in-place editing, which means it will modify the file directly, so make sure you have a backup if you're unsure. Also, `print0` and `-0` options in `find` command are used so that when all the files are concatenated using `xargs`, there won't be any null-byte expansion issues.
assistant
write a bash script to look for these two lines in a directory of .sql files :
"sis\_source\_id" character varying(255),
CONSTRAINT "pk\_accounts" PRIMARY KEY ("id")

and then insert the folowing line:
"ts" timestamp without time zone NOT NULL,
user
Sure, here's a simple bash script that should do the job:

```bash
#!/bin/bash

# Directory where the .sql files are located
dir="/path/to/your/sql/files"

# Loop over all .sql files in the directory
for file in "$dir"/*.sql
do
    # Check if the two lines exist in the file
    if grep -q 'sis_source_id" character varying(255),' "$file" && grep -q 'CONSTRAINT "pk_accounts" PRIMARY KEY ("id")' "$file"; then
        # If they do, insert the new line after the second line
        sed -i '/CONSTRAINT "pk_accounts" PRIMARY KEY ("id")/a "ts" timestamp without time zone NOT NULL,' "$file"
    fi
done
```

Please replace `"/path/to/your/sql/files"` with the actual path to your SQL files.

This script will go through each .sql file in the specified directory, check if the two lines exist in the file, and if they do, it will insert the new line after the second line.

Please make sure to backup your files before running this script, as the `sed -i` command will modify the files in-place.
assistant