Skip to main content
23 events
when toggle format what by license comment
S Oct 15, 2020 at 15:27 history suggested Lanre CC BY-SA 4.0
Add similar commands on mac os x
Oct 13, 2020 at 8:29 review Suggested edits
S Oct 15, 2020 at 15:27
Jun 19, 2020 at 10:20 comment added stephanmg Is this also Sh compatible?
Jan 31, 2020 at 15:20 comment added Xælias For what it's worth the cat version is around 3 times faster than the sed ones. At least on the test in did on a ~4GB file.
Mar 13, 2019 at 15:06 comment added Simon Lindholm The sed versions don't seem to work on an empty file.
Sep 29, 2017 at 18:17 review Suggested edits
Sep 29, 2017 at 19:18
Jul 20, 2016 at 21:14 comment added Terrance @DennisWilliamson Unfortunately the sed doesn't recognize the \t as tab. I forgot to say that I had to do it as echo -e to make it work with the tab.
Jul 20, 2016 at 21:07 comment added Dennis Williamson @Terrance: If your sed command looks something like this (inserting a leading tab): '1i\tSome Text', you may need to double the backslash. Otherwise, your dialect of sed may not recognize \t as tab.
Jul 20, 2016 at 20:37 comment added Terrance The echo line works perfect for DD-WRT firmware for a script I run. Using sed and putting in the \t for a tab, puts just a t then the next part. Where the echo line actually puts the tab in instead of the t. Thank you!
Oct 23, 2015 at 16:33 comment added Dennis Williamson @Kira: The 1 means do the next command only on line one of the file and the i command is insert. Look in the man page under the "Addresses" section and in the "Zero- or One- address commands" section.
Oct 22, 2015 at 19:04 comment added Kira I didn't know about this possible syntax in sed's last example, can someone tell me what is the name of this type of syntax so I can search more about it?
Aug 22, 2015 at 19:28 comment added Dennis Williamson @onaclov2000: The second sed command in my answer says to insert a line of text before line 1. I'd have to see the command you used to know why it inserted it on every other line. You probably omitted the address (1).
Aug 22, 2015 at 17:15 comment added onaclov2000 Using the third option, I got the task in the file every other line....so I guess it put it on the first line, but didn't do so well for the rest of the file for my use case.
Aug 5, 2014 at 10:14 comment added SF. cat can be freely used to concatenate binaries. Note how split and join do entirely different things; cat is the companion to split, not join. And that means, if your cat messed up \n your implementation is horribly broken.
Jan 27, 2014 at 15:24 comment added Felix Using 2 and 3 (3 seems simpler to me) allows you to prepend text to many files at once.
Jan 26, 2014 at 21:58 comment added Dennis Williamson @itaifrenkel: I'd have to see what you did, but if cat receives a literal backslash n, it won't convert it to a newline. Something else must have done that. Instead of cat, try piping into hexdump -C to see if you're actually sending backslash and n or if it's a newline. You could also try cat -e to show line endings.
Jan 26, 2014 at 21:37 comment added itaifrenkel Instead of printing \n it may print a newline. Happened to me. Used the sed version just fine instead
Jan 26, 2014 at 12:16 comment added Dennis Williamson @itaifrenkel: In what way?
Jan 26, 2014 at 8:50 comment added itaifrenkel cat could be a problem if cat encounters \n
Feb 18, 2011 at 4:51 comment added Dennis Williamson @user8347: Pipe (|) the message (echo '...') to cat which uses - (standard input) as the first file and todo.txt as the second. cat conCATenates multiple files. Send the output (>) to a file named temp. If there are no errors (&&) from cat then rename (mv) the temp file back to the original file (todo.txt).
Feb 18, 2011 at 4:24 vote accept user479534
Feb 18, 2011 at 4:24 comment added user479534 the first one works great! would you mind explaining the logic? im not particularly sure how to interpret the syntax.
Feb 17, 2011 at 3:34 history answered Dennis Williamson CC BY-SA 2.5