-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
sed expression fixed #32
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Quotes are not the problem here. Rather, you want to remove the g
so that the substitution only applies to the first match per line instead of every match.
@@ -37,13 +37,13 @@ for line in $(select_rows "select distinct guid from chat;" ); do | |||
select is_from_me,text, datetime((date/1000000000) + strftime('%s', '2001-01-01 00:00:00'), 'unixepoch', 'localtime') as date from message where handle_id=( | |||
select handle_id from chat_handle_join where chat_id=( | |||
select ROWID from chat where guid='$line') | |||
)" | sed 's/1\|/Me: /g;s/0\|/Friend: /g' > $BACKUP_DIR/$contactNumber/$line.txt | |||
)" | sed 's/'1\|'/Me: /g;s/'0\|'/Friend: /g' > $BACKUP_DIR/$contactNumber/$line.txt |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
)" | sed 's/'1\|'/Me: /g;s/'0\|'/Friend: /g' > $BACKUP_DIR/$contactNumber/$line.txt | |
)" | sed 's/1\|/Me: /;s/0\|/Friend: /' > $BACKUP_DIR/$contactNumber/$line.txt |
else | ||
select_rows " | ||
select is_from_me,text, datetime(date + strftime('%s', '2001-01-01 00:00:00'), 'unixepoch', 'localtime') as date from message where handle_id=( | ||
select handle_id from chat_handle_join where chat_id=( | ||
select ROWID from chat where guid='$line') | ||
)" | sed 's/1\|/Me: /g;s/0\|/Friend: /g' > $BACKUP_DIR/$contactNumber/$line.txt | ||
)" | sed 's/'1\|'/Me: /g;s/'0\|'/Friend: /g' > $BACKUP_DIR/$contactNumber/$line.txt |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
)" | sed 's/'1\|'/Me: /g;s/'0\|'/Friend: /g' > $BACKUP_DIR/$contactNumber/$line.txt | |
)" | sed 's/1\|/Me: /;s/0\|/Friend: /' > $BACKUP_DIR/$contactNumber/$line.txt |
The sed expression on bash matches with almost every character, creating text files full of Me: Friend:Me: Friend. Enclosing it in single quotes allows sed to process the 1 as is and includes the escape character |