Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8954673
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T14:21:42+00:00 2026-06-15T14:21:42+00:00

I am writing a KornShell (ksh) script that is logging to a file. I

  • 0

I am writing a KornShell (ksh) script that is logging to a file. I am redirecting the output of one of my commands (scp) to the same file, but I would like to add a tab at the start of those lines in the log file if possible.

Is this possible to do?

EDIT: Also I should mention that the text I am redirecting is coming from stderr. My line currently looks like this:

scp -q ${wks}:${file_location} ${save_directory} >> ${script_log} 2>&1
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T14:21:43+00:00Added an answer on June 15, 2026 at 2:21 pm

    Note: the below doesn’t work for ksh (see this question for possible solutions).


    You probably can do something like

    my_command | sed 's/^/\t/' >> my.log
    

    The idea is to process the output of the command with a stream editor like sed in some manner. In this case, a tab will be added at the beginning of every line. Consider:

    $ echo -e 'Test\nfoobar' | sed 's/^/\t/'
        Test
        foobar
    

    I haven’t tested this in ksh, but a quick web search suggests that it should work.

    Also note that some commands can write to both stdout and stderr, don’t forget to handle it.

    Edit: in response to the comment and the edit in the question, the adjusted command can look like

    scp -q ${wks}:${file_location} ${save_directory} 2>&1 | \
        sed 's/^/\t/' >> ${script_log}
    

    or, if you want to get rid of stdout completely,

    scp -q ${wks}:${file_location} ${save_directory} 2>&1 >/dev/null | \
        sed 's/^/\t/' >> ${script_log}
    

    The technique is described in this answer.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am writing a shell script to run under the KornShell (ksh) on AIX.
Writing a script that cds into another dir, loads the correct rvm rvmrc file,
Writing a recursive function, I want one fn that executes when the list has
Writing a small command line tool, it would be nice to output in different
Writing a simple program that will find exact duplicate files on my computer, but
writing to a text file is working good...But my problem is text file is
Writing a Jabber client that uses Twisted Words. I would like to know an
Writing a plugin for [top-secret] (not really :P) and I decided that one best
Writing htaccess that allows me to remove index.php from the URL can confuse search
Writing documentation in html requires some code examples. What to do with characters that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.