Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

5
  • 1
    You want to indent everything but the first line by two tabs, or do you want to insert the literal string \t\t? Are you adding this array to another JSON file? If so, it would be better to do that withjq directly rather than via some sed processing. Commented May 10, 2024 at 11:11
  • No i'm not adding this in another json file, but in a another text configuration file. And isn't inserting \t\t equal to indenting by two tabs? Commented May 10, 2024 at 12:29
  • You never once mention the word "tab" in th e question, which is why I was wondering whether you meant the two characters \ and t, or a literal tab character. Also, you seem to have accepted an answer, even though this generates output that is not like that in the question (the tabs are at the start of the line rather than at the start of each element). Since you mentioned "before each element" rather than "at the start of the line", I thought this was an important distinction to make. Commented May 10, 2024 at 13:29
  • Whether it's at the end or beginning it wouldn't matter, because whether I have ' \t\t' or '\t\t ' is similar at the end. Commented May 10, 2024 at 13:41
  • @kyles the point is it's not clear from your question if you want the 4 characters \, t, \, t or 2 literal tab characters inserted. Inserting \t\t is not the same as inserting 2 tab chars, \t is an escape sequence that some tools will use in output statements to generate tab chars but that doesn't mean \t is a tab char, and at no point do you say in your question that you want tab characters but instead show literal \ts in your expected output. If you're going to show that then at least say "those \ts are literal tab chars" or similar in your question. Commented May 10, 2024 at 15:31