How to add space in front of cat values?

Hi,

Hope you are all doing fine.

The problem today i faced during my coding was i wanted to add a space equals to a tab character in front of all the lines which i am cat using tee command.

Main file contents

mainfile

1,/level1/level2/CAP_data.171002/20171002_060344_53608614,20171002_060344_53608614
2,/level1/level2/20171005_023901_56688702,20171005_023901_56688702
3,/level1/level2/20171005_023903_13697660,20171005_023903_13697660
4,/level1/level2/20171005_023905_33947650,20171005_023905_33947650
5,/level1/level2/20171005_023906_11666112,20171005_023906_11666112
6,/level1/level2/20171005_023908_49545338,20171005_023908_49545338
7,/level1/level2/20171005_023911_18875126,20171005_023911_18875126
8,/level1/level2/20171005_023913_36372644,20171005_023913_36372644
9,/level1/level2/20171005_023915_3539570,20171005_023915_3539570
cat $mainfile  | tee -a $log

I am actually cat'ting the file content to a user menu and a log file i want to add space in front of all the lines shown above it should be regardless of the no of lines in the file content!!
like below snap shot.

	1,/level1/level2/CAP_data.171002/20171002_060344_53608614,20171002_060344_53608614
	2,/level1/level2/20171005_023901_56688702,20171005_023901_56688702
	3,/level1/level2/20171005_023903_13697660,20171005_023903_13697660
	4,/level1/level2/20171005_023905_33947650,20171005_023905_33947650
	5,/level1/level2/20171005_023906_11666112,20171005_023906_11666112
	6,/level1/level2/20171005_023908_49545338,20171005_023908_49545338
	7,/level1/level2/20171005_023911_18875126,20171005_023911_18875126
	8,/level1/level2/20171005_023913_36372644,20171005_023913_36372644
	9,/level1/level2/20171005_023915_3539570,20171005_023915_3539570

Kindly help me out for this.

Not sure I totally follow. Some punctuation would not go a miss :wink:

$ sed "s/^/  /" t.txt
  1,/level1/level2/CAP_data.171002/20171002_060344_53608614,20171002_060344_53608614
  2,/level1/level2/20171005_023901_56688702,20171005_023901_56688702
  3,/level1/level2/20171005_023903_13697660,20171005_023903_13697660
  4,/level1/level2/20171005_023905_33947650,20171005_023905_33947650
  5,/level1/level2/20171005_023906_11666112,20171005_023906_11666112
  6,/level1/level2/20171005_023908_49545338,20171005_023908_49545338
  7,/level1/level2/20171005_023911_18875126,20171005_023911_18875126
  8,/level1/level2/20171005_023913_36372644,20171005_023913_36372644
  9,/level1/level2/20171005_023915_3539570,20171005_023915_3539570

(no need for cat)

Should those "spaces" occur in both the user menu and the log file, or, if not, in which of them?

This will insert a TAB at the beginning.

cat  $mainfile  | xargs -i echo "\t{}" | tee -a  $logfile

Hi All,

Thank you for all your reply i tried all the solutions given here but not fruitful.
I ended up in while loop for this issue and it is working.

Thanks.