5

Replace leading space(s) from beginning of line by one tab

view full story
linux-howto

http://www.unix.com – hello does someone want to help me for this one ? in text files i want to replace leading space(s) from beginning of line by one tab when there are space(s) with the sed code Code: sed -i".bak" 's/^[ \t]*/\t/' *.txt; rm *.bak the result is tabs on every line, i only want to add when the spaces are existing thanks for you help ! i put different others codes in case of someone need them Code: sed 's/  */ /g' or Code: sed 's/ \{1,\}/ /g' or Code: tr -s ' ' replace multiple spaces by one space Code: perl -p -i -e 's/\s+/\t/g' *.txt or Code (HowTos)