Tag Info

New answers tagged

6

The GNU grep can do it grep -z 'is\san\sexample\sfile.' file To fulfill some points which arise in comments there are some modifications to script: grep -oz '^[^\n]*\bis\s*an\s*example\s*file\.[^\n]*' file Regarding huge files I have no imagination of memory limitation but in the case of problem you are free to use sed sed '/\bis\b/{ :1 ...


6

Try this: pcregrep -M '\bThis\s+is\b' <<EOT This is an example file. EOT


1

Use an array: echo '<name>,<tag1> <tag2> <tag3>' | while IFS=" ," read -a foo; do echo ${foo[@]}; done Output: <name> <tag1> <tag2> <tag3> From man bash: IFS: The Internal Field Separator that is used for word splitting after expansion and to split lines into words with the read builtin command.


0

The vi/vim/ex editors automatically add <EOL> at EOF unless file already has it. So try either: vi -ecwq foo.txt which is equivalent to: ex -cwq foo.txt Testing: $ printf foo > foo.txt && wc foo.txt 0 1 3 foo.txt $ ex -scwq foo.txt && wc foo.txt 1 1 4 foo.txt To correct multiple files, check: How to fix 'No newline at end ...


1

dos2unix: sed -i -r -e 's/\r$//' file unix2dos: sed -i -r -e 's/$/\r/' file


2

Windows line endings consist of the two-character sequence CR, LF. CR is the carriage return character, sometimes represented as \r, \015, ^M, etc. A Unix line ending is just the LF character. A way to convert Windows line endings to Unix line endings using only standard utilities present on all Unix variants is to use the tr utility. tr -d '\r' ...


0


2

I don't think this likely has anything to do with the mounting. Are you sure the CR characters are there originally in the file? Assuming they are not, you can use unix2dos to add them, though I haven't actually verified that exists for AIX. You could use sed like sed -i -e 's/\n/\r\n/g' <file> if you don't have unix2dos available. The -i flag ...


1

It doesn’t matter how you mounted the partition. Every byte of every file will be transferred. If your files do not have carriage returns after the transfer, then they didn’t have them before. I don’t know what command to run on AIX to check the encoding of your files, but you could just look at them in a binary editor and see if the lines are terminated ...



Top 50 recent answers are included