sed: -e expression #1, char 3: unexpected `,'

prof chaos

i run the script by using ./myshfile.sh actors

sed -n -e "1,$1p" test.txt > test2.txt && mv test2.txt test.txt

produces the following error and i can't find why...

sed: -e expression #1, char 3: unexpected `,'

tried to use single quotes

sed -n -e '1,$1p' test.txt > test2.txt && mv test2.txt test.txt

but that produces another error

sed: -e expression #1, char 4: unknown command: `1'
ilkkachu

In "1,$1p", the $1 is expanded by the shell, and sed sees 1,actorsp. actorsp isn't a valid sed address, so it gives an error. The error text looks a bit weird to me though, it seems to recognize a as a command and then go back to wondering about the comma.

In '1,$1p', the $1 is not expanded by the shell, and sed sees 1,$1p. $ is a valid address, it's used to mark the last line, so 1,$ simply means "all lines". 1 isn't a valid command though, so an error it is.

You didn't state what you meant to do, so it's hard to help there.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

sed: -e expression #1, char 23: unknown option to `s'

From Dev

sed expression , char xx: Invalid range end error caused by hyphen

From Dev

Syntax error: "(" unexpected when using GNU sed with 'e' flag

From Dev

CloudKit Unexpected Expression for NSPredicate

From Dev

SyntaxError: Unexpected token e in JSON at position 1

From Dev

sed: -e expression #1, char 4: unknown command:

From Dev

sed throwing sed: -e expression #(number), char (number): unknown command: `(letter)'

From Dev

bash - sed: -e expression #1, char 15: unterminated `s' command

From Dev

Getting "sed: -e expression #1" when trying to run search and replace

From Dev

sed throwing sed: -e expression #(number), char (number): unknown command: `(letter)'

From Dev

sed: -e expression #1, char 44: unterminated address regex

From Dev

Why does sed output -e expression #1, char 55: Invalid preceding regular expression

From Dev

sed: -e expression #1, char 35: unterminated `s' command

From Dev

sed: -e expression #1, char 1: unknown command: `''

From Dev

sed: -e expression #1, char 37: unterminated `s' command

From Dev

sed: -e expression #1, char 10: missing command

From Dev

/bin/sed: -e expression #1, char 56: unknown option to `s'

From Dev

Error in the simple shell script ( i.e.+ : unexpected `end of expression' )?

From Dev

sed: -e expression #3, char 59: unknown option to `s'

From Dev

`sed: -e expression #1, char 4: unknown command:` but the line endings are fine

From Dev

sed Error sed: -e expression #1, char 7: unterminated `s' command

From Dev

Sed expression for IP address, getting unexpected result for matching group

From Dev

sed: -e expression #1, char 1: unknown command: '|'

From Dev

bash sed: -e expression #1, char 21: number option to `s' command may not be zero

From Dev

sed: -e expression #1, char 10: extra characters after command

From Dev

sed: -e expression #1, char XX: unterminated `s' command

From Dev

Python 3 regular expression returning unexpected result

From Dev

sed: -e expression #1, char 5: unterminated `s' command

From Dev

Regular Expression to parse 112^3^1^1^

Related Related

  1. 1

    sed: -e expression #1, char 23: unknown option to `s'

  2. 2

    sed expression , char xx: Invalid range end error caused by hyphen

  3. 3

    Syntax error: "(" unexpected when using GNU sed with 'e' flag

  4. 4

    CloudKit Unexpected Expression for NSPredicate

  5. 5

    SyntaxError: Unexpected token e in JSON at position 1

  6. 6

    sed: -e expression #1, char 4: unknown command:

  7. 7

    sed throwing sed: -e expression #(number), char (number): unknown command: `(letter)'

  8. 8

    bash - sed: -e expression #1, char 15: unterminated `s' command

  9. 9

    Getting "sed: -e expression #1" when trying to run search and replace

  10. 10

    sed throwing sed: -e expression #(number), char (number): unknown command: `(letter)'

  11. 11

    sed: -e expression #1, char 44: unterminated address regex

  12. 12

    Why does sed output -e expression #1, char 55: Invalid preceding regular expression

  13. 13

    sed: -e expression #1, char 35: unterminated `s' command

  14. 14

    sed: -e expression #1, char 1: unknown command: `''

  15. 15

    sed: -e expression #1, char 37: unterminated `s' command

  16. 16

    sed: -e expression #1, char 10: missing command

  17. 17

    /bin/sed: -e expression #1, char 56: unknown option to `s'

  18. 18

    Error in the simple shell script ( i.e.+ : unexpected `end of expression' )?

  19. 19

    sed: -e expression #3, char 59: unknown option to `s'

  20. 20

    `sed: -e expression #1, char 4: unknown command:` but the line endings are fine

  21. 21

    sed Error sed: -e expression #1, char 7: unterminated `s' command

  22. 22

    Sed expression for IP address, getting unexpected result for matching group

  23. 23

    sed: -e expression #1, char 1: unknown command: '|'

  24. 24

    bash sed: -e expression #1, char 21: number option to `s' command may not be zero

  25. 25

    sed: -e expression #1, char 10: extra characters after command

  26. 26

    sed: -e expression #1, char XX: unterminated `s' command

  27. 27

    Python 3 regular expression returning unexpected result

  28. 28

    sed: -e expression #1, char 5: unterminated `s' command

  29. 29

    Regular Expression to parse 112^3^1^1^

HotTag

Archive