The newlines tag has no wiki summary.
17
votes
4answers
16k 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
1answer
88 views
array[@] output all messed up?
I've got this code:
Unix+=("Stock List")
while read line; do
result=$(wget -O - -o /dev/null "http://finance.yahoo.com/d/quotes.csv?s=$line&f=sl1&e=.csv" | tr ',' ' ' | tr '"' ' ')
...
4
votes
4answers
914 views
concatenate two files without adding a newline
If I nano two files, one of which reads 'this' without me entering a newline, and one of which reads 'is' without me entering a newline, I want to be able to then cat the two files together into ...
4
votes
2answers
5k views
Removing all spaces, tabs, newlines, etc from a variable?
This is the error I am getting and it's failing because of a variable whose value is supposed to be 2 (I am getting this using a select * from tabel).
I am getting spaces in that variable.
+ 0 !=
...
4
votes
2answers
911 views
Collapsing a stream of multiple lines into one line
I have a file containing a a large number of lines, each of which contains a bunch of numbers which are separated by spaces. I process this data in a pipe in some way, and then I want to collapse the ...
4
votes
2answers
613 views
Finding all “Non-Binary” files
Is it possible to use the find command to find all the "non-binary" files in a directory? Here's the problem I'm trying to solve.
I've getting an archive of files from a windows user. This archive ...
3
votes
2answers
236 views
Character count in Unix wc command
When I give wc command on a file with contents given below, it gives the number of characters as 30. Does it include the end of file character? Since including the space and newline there are only 29 ...
3
votes
1answer
271 views
Does input redirection (<) append a newline character?
I was originally of the impression that
$ ./myprog
moo[CTRL-D]
is exactly the same as
$ echo moo > cow
$ ./myprog < cow
But I found that myprog always counts one more \n in the second ...
3
votes
2answers
302 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
2answers
173 views
view file containing ISO-8859 text, CRLF line terminators, and escape sequences
I have stumbled upon a strange text file in an archive of an old dos game downloaded from some abandonware site.
The text file is named WHY_NOT.TXT. I assume the file is some sort of .NFO file from ...
2
votes
2answers
125 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 ...
2
votes
1answer
120 views
Insert newlines with vim
How to insert newlines in vim?
For example in a file containing
test-classes; classes; xmlunit-1.3.jar
I am looking for the vim equivalent of sed command
sed -i 's/; /\n/g' classpath
to obtain
...
2
votes
1answer
90 views
How to `tee` dropping all CR lines only in the file but not stdout?
When using e.g. rsync, I'd like to tee its output such that I can both view the current progress live, and have a log for later. Using just piping | tee logfile the logfile will contain many lines à ...
2
votes
5answers
62 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
3answers
158 views
How to read '\n' into variable with Bash's built-in command?
Somehow I'm not able to read the trailing \n sign into the REPLY variable. Under any circumstances I want to avoid a blank line that results from the \n being echoed by read but echo one in case of ...
1
vote
1answer
58 views
Why is it that , to newline is working but newline to , is not working sed?
I have got a text file with a list of first names, and I am trying to replace newline with ,.
Here is the command I am using
sed 's/\
/,/g' file
while the reverse is working
sed 's/,/\
/g' file
...
1
vote
3answers
310 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 ...
1
vote
2answers
64 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 ...
0
votes
1answer
63 views
How can I preserve new lines coming from a command's output during variable assignment?
Consider:
$ getfacl somefile.dat # The output is formatted and contains several new lines..
# file: somefile.dat
# owner: user1
# group: group1
user::rw-
group::r-- #effective:r--
...
0
votes
4answers
585 views
How to detect dos format files in git bash
Git Bash is a nice bash shell you get in Windows as part of the installation of Git. It comes with other typical unix tools bundled inside, such as grep, sed, awk, perl. It doesn't have the file ...
0
votes
1answer
1k 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 ...
0
votes
3answers
40 views
Make VIM act as Notepad++ on mixed line endings
I've googled all around and found tons of weird solutions to ^M problem, but couldn't find one and simple: how could I just open any file, like in Notepad++ and work on it? I don't want to mess with ...
0
votes
1answer
133 views
what is the best way to convert CRLF to LF and the viceversa for C++ files in my project [duplicate]
Possible Duplicate:
How to bulk convert all the file in a file system branch between Unix and Windows line break format?
which is the best tool to convert the CRLF to LF for my project in ...
0
votes
1answer
73 views
What does this “matching lines means”?
The grep manual says "By default, grep prints the matching lines.". What does this matching lines says. When I tried its prints the whole paragraph containing the pattern.