Tag Info

New answers tagged

2

There is difference between renaiming and moving to somewhere. In the case easyest way (in modern bash) is loop through all files: for f in *.* do d=${f::1}/${f:1:1} [ -d "$d" ] || mkdir -p "$d" mv "$f" "$d" done


0

Sed or awk are one-line editors. You have to join two lines in one or use options (exist in GNU sed versions > 4.2.1) sed -zi 's~Assurez-vous de bien recevoir tous nos messages en ajoutant bebeco@cab05\.net a votre carnet d'\''adresses.<br />\n Si vous avez des difficult\\&eacute;s pour visualiser ce message, rendez-vous sur~[{headerbebeco}]~g' ...


1

To collect all comments to OP: by cut (set field delimiter to " and print second field just from lines where delimiter exist): cut -sd\" -f2 by grep jimmij (find the pattern and print it part after \K only): grep -Po 'anm="\K[^"]*' by awk jasonwryan (set field delimiter to " and print second field): awk -F\" '{print $2}' by sed (substitute all line ...


0

You can extract the anm="..." part with grep like this: grep -Eo 'anm="[^"]*"' file The -o option to grep only outputs the part of a line that matches. Then remove both the anm=" at the beginning and " at the end of each line: grep -Eo 'anm="[^"]*"' file | sed -e 's/^anm=\"//' -e 's/\"$//'


0

This makes the same assumption about spaces as @Gilles answer does, but it eschews the while...read loop. It first backslash escapes any occurrence of any of sed's BRE metacharacters, then prints its current line number, then globally substitutes every pair of not-space characters it can find into a working sed substitution statement. Next in the pipeline a ...


1

using egrep egrep '^.{3,10}$' matches from begining to ending of lines for 3 or more character but less than or equal to 10 characters.


2

grep -x '.\{3,10\}' where -x match pattern to whole line . any symbol {3,10} quantify from 3 to 10 times previous symbol (in the case any ones)


2

sed "s/.\{$(($RANDOM%${#a}))\}/&$b/" <<< $a where: $RANDOM pseudo-random value from 0 to $RAND_MAX (usually 0x7fff == 32767) ${#a} length of target string $((...%...)) outputs the resedue from dividing .{n} match first n characters of input string s/.../&$b/ substitutes pattern match by themselves + $b


0

an attempt in awk: awk "{srand(); i=int(rand()*length(\$0)); print substr(\$0,0,i)\"${b}\"substr(\$0,i)}" <<< $a


2

Yes. You can do that w/ tr in an ASCII locale (which is, for a GNU tr anyway, kind of its only purview). You can use the POSIX classes, or you can reference the byte values of each character by octal number. You can split their transformations across ranges, as well. LC_ALL=C tr '[:upper:]\0-\101\133-140\173-\377' '[:lower:][\n*]' <input The above ...


2

Here's something I cobbled up using the CSV module: #! /usr/bin/env python3 import csv, sys word_list = ['fcv=demelog','fcv=voyapro','fcv=naisjdf','fcv=naismc','fcv=decoide','fcv=decoccm','fcv=travide','fcv=travccm','fcv=equiccm','fcv=mariccm'] csvin = csv.reader (sys.stdin, delimiter=';') csvout = csv.writer (sys.stdout, delimiter=';') for row in csvin: ...


4

Here are a few approaches: GNU grep and tr: find all words and make them lower case grep -Po '\w+' file | tr '[A-Z]' '[a-z]' GNU grep and perl: as above but perl handles the conversion to lower case grep -Po '\w+' file | perl -lne 'print lc()' perl: find all alphabetic characters and print them in lower case (thanks @steeldriver): perl -lne 'print lc ...


5

You can combine multiple translations (excepting complex cases involving overlapping locale-dependent sets), but you can't combine deletion with translation. <doyle_sherlock_holmes.txt tr -d '[:punct:]' | tr '[:upper:] ' '[:lower:]\n' Two calls to tr are likely to be faster than a single call to more complex tools, but this is very dependent on the ...


1

If you like awk: awk -F' *[."]' ' { FName[$2]=1 RName[$1]=1 Data[$1,$2]=$3 } END{ printf("%s;","RECORDNAME") for (f in FName) printf ("%s;",f) print "" for (i in RName){ printf ("%s",i) for (j in FName) printf ("%s;",Data[i,j]) print "" } }' text.file Outputs: ...


2

There are a couple of tricky things with CSV: a field contains an embedded field separator, or a field contains embedded quotes. I added 2 lines to your sample data: TEST_AB.foo " with "embedded quotes" here TESTRICU=L.foo " with an inner; semicolon And a scary perl solution is: save this in a file named "text2csv.sh" #!/bin/sh perl -lne ' @F = ...



Top 50 recent answers are included