How i can delete whitespace in each line of file, using bash
For instance, file1.txt. Before:
gg g
gg g
t ttt
after:
gg g
gg g
t ttt
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.
sed -i 's/ //g' your_filewill do it, modifying the file inplace.To delete only the whitespaces at the beginning of one single line, use
sed -i 's/^ *//' your_fileIn the first expression, we replace all spaces with nothing.
In the second one, we replace at the beginning using the
^keyword