Tag Info

New answers tagged


One aspect of this problem isn't really about awk - and only a little bit about the shell. The problem is that on a standard, canonical tty most of the time the kernel's tty discipline is buffering your input - just echoing it to your screen and nowhere else - so that it can efficiently handle backspacing and such-like. However, when you press return or ...


I know you asked for a mv solution, however, despite the warning, this can be easily done with rename (in the Perl package): ~/tmp$ touch foo ~/tmp$ rename 's/$/\nbar/' foo Unsuccessful stat on filename containing newline at /usr/share/perl5/File/Rename.pm line 69. ~/tmp$ ls foo?bar


If you use bash, this command should work. mv a $'b\nc'


It is a bad idea (to have strange characters in file names) but you could do mv somefile.txt "foo bar" (you could also have done mv somefile.txt "$(printf "foo\nbar")" or mv somefile.txt foo$'\n'bar, etc... details are specific to your shell. I'm using zsh) Read more about globbing, e.g. glob(7). Details could be shell-specific. But understand that ...


If you just want to quickly add a newline when processing some pipeline, use this: outputting_program | { cat ; echo ; } it's also POSIX compliant. Then, of course, you can redirect it to a file.


The mobyposi.i file uses old-style Mac line endings, i.e. CR characters. Why? I don't know. This file is from 1993, maybe the author wanted to be Mac-friendly and thought Unix and Windows users could fend on their own. Or maybe the author made a mistake, the readme file states that “the vocabulary file [has] CRLF (ASCII 13/10) delimiters” whereas the ...


Others have stated that the "Implicit LF with CR" and Implicit CR with LF" ONLY control how PuTTY interprets what is coming IN. An IMPLICIT CR or LF wouldn't have much value down the wire. A command for an EXPLICIT CR or LF would be handy, but that doesn't seem to be available.


If you want to keep the same code as you currently have, I suggest using sed a little more to its capacity : i="`sed -n 's/'$'\r''//;s/,/ /g;s/values=//gp' /usr/local/app1/default.conf`" for data in $i; do cp -rvp /usr/local/dir1/$data.png /home/user1/dir1 done How it works : The -n flag to sed tells it to not print the lines automatically The ...


You probably edited that default.conf file on windows machine and copied it over. There seems to be an extra character at the end of that line before the newline. Try od -c default.conf. It probably gives you something like: 0000000 v a l u e s = w a d s s e a 0000020 d s e d a o k a w w ...


Actually I didn't get your use case, but all I understood is you want to find .png files from a directory and want to copy those files to another directory.If my understanding about your use case is correct then the below command helps, find /home/your/source/path/ -name \*.png -exec cp {} /home/your/destination/path/ \;


From the (broken) code snippet you posted, you seem to want to replace the newline as well. In that case, regex anchoring by itself can't help you. The following is a solution: sed '/[[:alpha:]]\+$/{N;s/[[:alpha:]]\+\n/replace/}' your_file Broken down: /[a-zA-Z]\+$/{} means apply whatever comes inside the curlies to lines that match the regex. The ...


Regular expressions can be anchored at the end of the line using $ (or at the beginning, using ^). If you want to replace anything matching the pattern [A-Za-z]* at the end of the line with something, then anchoring the pattern like this: [A-Za-z]*$ ...will force it to match at the end of the line and nowhere else. However, since [A-Za-z]*$ also matches ...


Unix represents newlines with the character LF (line feed = \n = ^J = 10 decimal = 012 octal = 0x0a hexadecimal). Windows represents newlines with the two-character sequence CR, LF (CR = carriage return = \r = ^M = 13 decimal = 015 octal = 0x0d hexadecimal). When a Windows text file is processed by a Unix utility, each line thus ends with a spurious CR ...


sed "s/[a-zA-Z]*$/replace/" input.txt > result.txt Or, the long complex unnecessary way: I've found out, this can be done, still using sed, with the help of tr. You can assign another character to represent the end of the line. Another temporary character has to be used, in this case "`". Let's use "~" to represent the end of the line: tr ...

Top 50 recent answers are included