How to remove these symbols with sed [closed] - linux

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 months ago.
Improve this question
Upon executing curl I get this kind of a response:
Timestamp:2022-09-19T09:43:15 \n
No:12 \n
Name: Provide a short description \n
Author:jsimpson \n
Description# Description\r\n\r\nThis is the description \r\n\r\n##Provide additional information.\r\n- [X] Address\r\n- [ ] Phone\r\n \n
\r\n
--- \n
How can I remove the following characters using sed command? #, [, ], \r ?

Construction like this can help you to remove these symbols:
sed 's/#//g; s/\[//g; s/\]//g; s/\\r//g'
it is just sequence of changes. Be aware some symbols need to be escaped.

Related

Remove Unorder Number From Sublime [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
i Have Data Like this
9372127603
9372130412
9372140
9372175041
937218
9372190908
9372191764
i need output like
9372127603
9372130412
9372175041
9372190908
9372191764
what i do to achieve this in sublime text ?
You can do this via regex Find and Replace. Open Find → Replace…, make sure the regex option is on, enter ^\d{1,9}\n into the Find: field, and make sure the Replace: field is empty:
Explanation:
^ beginning of line
\d any digit
{1,9} match preceding between 1 and 9 times, inclusive
\n newline character
test at Regex101
Once you've done that, hit Replace All and any numbers less than 10 digits long will be removed:

In Bash, how do I add a literal \n after each line? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 years ago.
Improve this question
I have a file which contains URL's separated by new lines.
After each URL, I would like to insert the literal character "\n".
How can I do so?
sed -i.BAK 's/$/\\n/' files
perl -i.BAK -pe 's/$/\\n/' files
check this example:
kent$ seq 5|sed 's/$/\\n/'
1\n
2\n
3\n
4\n
5\n

Remove entry based on the value of first column [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
If 3549,2152,4701 in first column then remove the entry:
sample data:
18106|1.0.4.0/22
3549|1.0.10.0/24
5413|1.0.0.0/16
2152|1.4.0.0/16
3549|1.0.8.0/22
4701|1.0.0.0/8
Expedted output:
18106|1.0.4.0/22
5413|1.0.0.0/16
How to achieve this?
For your pattern to match only on the first field you have to anchor the expression to the start of the line:
grep -v -E '^(3549|2152|4701)\|'
The ^ marks the beginning of the line (and $ would mark the end of the line)
The -E activates enhanced regular expressions so you don't have to \ escape pipes and parentheses, and the -v inverses the search (returning only lines that do not match).
The ^ matches the start of the line then parentheses with the pipe symbol marks alternatives (3549, 2152 or 4701), and \| stands for the pipe symbol itself which your first field ends with, and needs to be escaped by the backslash so it's not treated as another alternation.
Be careful to use single quotes around it because otherwise the shell itself will interpret some of the special characters.

sed how I can replace csv only IF line contain string? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 years ago.
Improve this question
I have a csv like this
titlemmmm;fff;ggg
mmmm;fff;ggg
mmmm;fff;ggg
I need to replace for obtain this
titlemmmm*fff*ggg
mmmm;fff;ggg
mmmm;fff;ggg
how I could do this
Please help me
You can use this:
sed '/title/s/;/*/g' file.txt
Or if you only want to match "title" at the beginning of a line:
sed '/^title/s/;/*/g' file.txt
If you want to edit the file in place, without needing to direct the output to a new file, you can use the -i option:
sed -i '/^title/s/;/*/g' file.txt

inserting a certain text between in every occurrence of two following tabs [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I am trying to insert NA between every occurrence of two tab characters immediately following each other in a text file. How can I do it with a sed command?
This might work for you (GNU sed):
sed ':a;s/\t\t/\tNA\t/g;ta' file
This covers all occurrances of \t\t throughout a file
Or if you prefer:
sed 's/\t\t/\tNA\t/g;s//\tNA\t/g' file
Like this:
sed 's/xx/xNAx/g' file
where you type x using Control-V TAB
Or, if you have GNU sed, you can type:
sed 's/\t\t/\tNA\t/g' file

Resources