Environment:
Operating system: CentOS
Background: shell script
Question:
sudo sed -n '842,${line}p' /.../file > ./file1
After execution, an error is reported:
– e expression # 1, char 7: extra characters after command.
Solution:
After investigation, it is found that it is OK to replace single quotation marks with double quotation marks, as follows:
sudo sed -n "842,${line}p" /.../file > ./file1
If none of the methods found work, try this one.
Remember that variables cannot be referenced within single quotes.
DONE!
Read More:
- [Solved] sed -i error: sed: -e expression #1, char 44: invalid reference \1 on `s’ command’s RHS
- SCP path contains special characters Error [How to Solve]
- WPF: How to Reference Font Resource File
- [Linux] undefined reference to `itoa’
- Linux: How to Fix undefined reference to `itoa’
- The JSON variable is parsed in the shell to obtain the value corresponding to the key
- [Solved] chroot: failed to run command ‘mount’: Exec format error
- [Solved] Ubuntu Compile Rust Program Error: failed to run custom build command for openssl-sys v0.9.39
- Solve the error report of the find command: paths must precede expression
- Termux setting path environment variable
- [Solved] UnicodeEncodeError: ‘ascii‘ codec can‘t encode characters in position 3-9: ordinal not in range(128)
- Linux system service command error: Failed to allocate directory watch: Too many open files
- Windows command execution bypass
- [Solved] find command error: paths must precede expression
- [Solved] yum Command Error: Error: Failed to download metadata for repo ‘appstream‘
- How to Use Apt get Command Under Mac OSX
- [Solved] ERROR: Linux route delete command failed: external program exited with error status: 2
- How to Solve Linux Error: -bash: unzip: command not found
- Mac opens Terminal and reports an error -bash:: command not found
- ./configure Command Execute error (Centos7 Install erlang)