Skip to content

Conversation

@mchangrh
Copy link

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 |

Copy link

@tagatac tagatac left a 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.

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
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
)" | 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

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
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
)" | 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants