The tag has no wiki summary.

learn more… | top users | synonyms

35
votes
4answers
5k views

What's the point in adding a new line to the end of a file?

Some compilers (especially C or C++ ones) give you warnings about: No new line at end of file I thought this would be a C-programmers-only problem, but github displays a message in the commit view: ...
2
votes
2answers
137 views

Directories are listed twice

I have something odd. I creates some directories using a very simple script : ... create all directories ( running under a user that has the correct rights ) e.g : mkdir -p ...
2
votes
3answers
849 views

How to bulk convert all the file in a file system branch between Unix and Windows line break format?

Everybody knows :-) that in Windows plain text files lines are terminated with CR+LF, and in Unix&Linux - with LF only. How can I quickly convert all my source code files from one format to ...
0
votes
1answer
2k views

Script failing with “command not found: ^M”

When I try to run the following script in zsh, via the command /bin/zsh ~/.set_color_scheme.sh I get the following error: command not found: ^M The script has u+x permissions and it used to work on ...
34
votes
6answers
32k views

How to add a newline to the end of a file?

Using version control systems I get annoyed at the noise when the diff says No newline at end of file. So I was wondering: How to add a newline at the end of a file to get rid off those messages?
5
votes
5answers
158 views

Automatic transformation of newlines in shell variable assignment

This came out of one of my comments to this question regarding the use of bc in shell scripting. bc puts line breaks in large numbers, e.g.: > num=$(echo 6^6^3 | bc) > echo $num ...
4
votes
3answers
450 views

How to skip file in sed if it contains regex?

I currently use the following simplified command to remove trailing whitespace and add a newline at end of file where needed: find . -type f -exec sed -i -e 's/[ \t]\+\(\r\?\)$/\1/;$a\' {} \+ As ...
2
votes
5answers
2k views

Carriage return issue

I have this in a bash script DAY2="20130605"<Cr> echo "This is yesterday date:"$DAY2"end" Why is the output the following? It seems as though there is a carriage return in DAY2 but where is ...
2
votes
2answers
201 views

Removing consecutive newlines with ed

Input file: 1 line1\ 2 line2\ 3 line3\ 4 \ 5 line4\ 6 \ 7 \ 8 line5\ Desired output: 1 line1 2 line2 3 line3 4 5 line4 6 7 line5 Is it possible with POSIX ed? Removing the trailing backslashes ...
1
vote
1answer
182 views

sed: N command does not read single line

Why sed's N command does not read single line? # single line without \n $ echo -en 'abc' | sed -n 'N;p' $ # I expected 'abc' # single line with \n $ echo -en 'abc\n' | sed -n 'N;p' $ # I expected ...