The newlines tag has no wiki summary.
0
votes
1answer
48 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--
...
3
votes
2answers
200 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 ...
1
vote
1answer
54 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
...
5
votes
1answer
80 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 '"' ' ')
...
2
votes
1answer
77 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
2answers
119 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
110 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
...
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.
2
votes
3answers
154 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 ...
0
votes
4answers
518 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
127 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
946 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 ...
3
votes
1answer
251 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 ...
4
votes
2answers
573 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 ...
4
votes
2answers
818 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
4answers
809 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 ...
3
votes
2answers
286 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 ...
3
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 !=
...
13
votes
4answers
14k 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?
1
vote
3answers
267 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 ...