Skip to content

Magenaut

  • Home
  • Topics
    • Notes
    • Tutorial
    • Bug fixing
    • Extension
    • Server
  • Q&A
  • Privacy Policy
  • About

sed

Remove comments in a C file

August 8, 2022 by Magenaut

I am trying to remove comments from a file which may be in any part of a line and span multiple lines. struct my_struct{ field1; field2; /** comment 1 */ field3; /* comment 2 */ } struct_name; I need to get struct my_struct{ field1; field2; field3; } struct_name; I tried using grep -o '[^/*]*[^*/]' to … Read more

Categories Q&A, Unix & Linux Tags grep, sed, source-code, text-processing Leave a comment

search and replace using grep (not sed)

August 8, 2022 by Magenaut

I’ve been reading about sed and found that it was evolved from grep command.

Categories Q&A, Unix & Linux Tags grep, sed Leave a comment

Replace line M in file1 with line N in file2

August 8, 2022 by Magenaut

Let M=3 and N=4. I want to replace line M in file1 with line N in file2. I can replace with a string using sed:

Categories Q&A, Unix & Linux Tags awk, sed, text-processing Leave a comment

How to delete blank lines starting from line 5

August 8, 2022 by Magenaut

I have this:

Categories Q&A, Unix & Linux Tags sed Leave a comment

Extra Backslash Required in First Appended Newline in sed

August 8, 2022 by Magenaut

While appending some text after a matched pattern, I wanted to add an empty line with a comment to isolate my additions from the rest. However, I have noticed that for the very first n, I need to escape the with an additional (makes it \n) but this is apparently not required for rest of the appended text. Why is this so?

Categories Q&A, Unix & Linux Tags sed Leave a comment

Why does sed act differently depending on the output file?

August 8, 2022 by Magenaut

If I run:

Categories Q&A, Unix & Linux Tags linux, pipe, sed Leave a comment

How can I redirect all output of a script to a file and replace passwords?

August 8, 2022 by Magenaut

I’m running a ksh script on AIX 7.2.

Categories Q&A, Unix & Linux Tags exec, ksh, password, sed Leave a comment

Match two words that is on the same line

August 7, 2022 by Magenaut

The command that I have prints out two of the lines whenever FW_6.0.0 is found, below is the code:

Categories Q&A, Unix & Linux Tags grep, sed, text-processing Leave a comment

Delete the nth line from a matched string (which only occurs once in the file)

August 7, 2022 by Magenaut

I have a question related to deletion of strings that appear at the n+2 position after the matched string which is at position n using awk for multiple files. I am able to print it using the command:

Categories Q&A, Unix & Linux Tags awk, sed, text-processing Leave a comment

Sed — Replace first k instances of a word in the file

August 7, 2022 by Magenaut

I want to replace only the first k instances of a word.

Categories Q&A, Unix & Linux Tags awk, sed, text-processing Leave a comment
Older posts
Newer posts
← Previous Page1 … Page8 Page9 Page10 Page11 Next →
  1. michealSmith07 on Is there a way to dynamically refresh the less command?August 21, 2022

    That is a very nice post. I like this post.

  2. anonymous on Fix libwacom9 dependency issue when upgrade DebianJune 27, 2022

    saved my day!! Thanks for the help…

  3. sreedhar on Fix libwacom9 dependency issue when upgrade DebianMay 10, 2022

    Thanks its working

  4. saintnick on Fix libwacom9 dependency issue when upgrade DebianMay 10, 2022

    remove libwacom2 worked for me as well

  5. ranafoul on Fix libwacom9 dependency issue when upgrade DebianApril 22, 2022

    apt remove libwacom2 helped on kali 2022.01. gr8

.net ajax asp.net asp.net-core asp.net-mvc asp.net-mvc-3 asp.net-mvc-4 asp.net-web-api bash c# command-line css custom-post-types custom-taxonomy dataframe dictionary django entity-framework functions gridview html iis javascript jquery json linux list matplotlib numpy pandas php plugin-development plugins posts python python-2.7 python-3.x security shell shell-script sql string vb.net webforms wp-query

© 2026 Magenaut • Built with GeneratePress