Handy One Liners

Convert a list of users into a SQL where clause

# Have to use " for sed, as we want to use the ' character in the output
cat users | sed "s/^/'/" | sed "s/$/',/" | tr '\n' ' ' | sed "s/^/(/" | sed "s/, $/)/" > users.out

Converts a column into a sql formatted parenthetical with tr and sed - have to use sed to handle the single quotes

grep -B 4 ERROR MDM-CORE-Import | grep , | cut -d " " -f 3 | tr "\n" "," | sed "s/,/\\',\\'/g"





Comments