I want to insert 4 blanks in a text named test.
sed 's/^/ \{4\}/' test
Why it can’t work?how can i do?
how about i want to add 10 blanks or 20 blanks?
sed 's/^/ /' test #can work ,but not well done
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
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.
nneonneo explained why your script didn’t work. It is fairly well known how to pad lines on the left with spaces to achieve lines of a fixed width, but adding the same number of blanks to the left a line for every line in sed is a different problem.
If you can bear to use something other than sed,
Or you can use
rubyOr you can use
awk:Or
perl:EDIT: I would like to see a pure
sedsolution. Using the conditional branch (t) seems useful for padding, but not to do what you ask.