Search Results

Search: Posts Made By: eldeingles
1,924
Posted By RudiC
I did a thorough analysis of the script and its...
I did a thorough analysis of the script and its results. There's no systematic error ignoring certain / certain length words. The algorithm to select characters is a rudimetary one and has its flaws...
1,924
Posted By RudiC
zeroth approximation .. you need to eliminate the...
zeroth approximation .. you need to eliminate the leading spaces in $2, no check is done to not to replace an already set "_" with another one, nor replacement of adjacent characters. Try



awk...
3,110
Posted By RudiC
The field / group separator must be different...
The field / group separator must be different from the word separator, e.g. spaces between words, <TAB>s between groups. Seems to be easier in awk than in pure shell, but try (recent shell, e.g. bash...
3,110
Posted By RudiC
Try also while read TMP; do echo $(shuf -e...
Try also
while read TMP; do echo $(shuf -e $TMP) | tr ' ' '\t' ; done <file
C B A
A C B
A B C
3,110
Posted By rdrtx1
awk -v rn=$RANDOM ' BEGIN { srand(rn); }...
awk -v rn=$RANDOM '
BEGIN {
srand(rn);
}
{
f=NF;
for (i=1 ; i<=f; i++) a[i]=i;
n=1;
while (n<4) {
d=int((rand() * f+1));
d=int((rand() * f+1));
if (d > 0 && d < f+1) {
...
1,341
Posted By Scrutinizer
Just replace the space in the replacement part...
Just replace the space in the replacement part with the character of your choice.
One caveat is that GNU sed understands \n , but regular sed needs a hard newline.
GNY sed:
sed...
1,341
Posted By Don Cragun
Try: sed 's,[^[]*\[\([^]]*\)\][^[]*,\1/,g ...
Try:
sed 's,[^[]*\[\([^]]*\)\][^[]*,\1/,g
s,/$,,' file
or, if you want to delete lines from the output for input lines that did not contain any words in square brackets:
sed -n...
1,985
Posted By Scott
If you're using a Mac, then: sed -i .bak...
If you're using a Mac, then:


sed -i .bak "s/\[[^]]*/[ /g" file


(ps: you did the right thing sticking with Snow Leopard ;))
1,985
Posted By Scott
An awk attempt: $ awk -v RS=[ -v FS=] '$2...
An awk attempt:

$ awk -v RS=[ -v FS=] '$2 {print $1}' file
have
in
are
in
is
but
hasn't
he
in
did
became
space
who
does
from
did
a
1,985
Posted By complex.invoke
sed 's/][^]]*\[/ /g' infile | sed...
sed 's/][^]]*\[/ /g' infile | sed 's/.*\[\([^]]*\).*/\1/'
3,323
Posted By bartus11
So you want to use TAB as word separator? Try...
So you want to use TAB as word separator? Try this:perl -F"\t" -lane 'use List::Util 'shuffle'; $,="\t";print shuffle(@F);' inputfile
3,323
Posted By kurumi
$ ruby -ne 'BEGIN{srand};puts...
$ ruby -ne 'BEGIN{srand};puts $_.split.shuffle.join(" ")' file
for test is shuffle a random this
$ ruby -ne 'BEGIN{srand};puts $_.split.shuffle.join(" ")' file
for random is shuffle a this test...
3,323
Posted By radoulov
awk 'BEGIN { srand() } { split(x, s) j...
awk 'BEGIN { srand() }
{
split(x, s)
j = int(NF * rand() + 1)
for (i = 0; ++i <= NF;) {
while (j in s) j = int(NF * rand() + 1)
printf "%s", ($j (i < NF ? FS : RS)); s[j]
}
...
1,179
Posted By malcomex999
Try... awk -F"[][]" '{for(i=0;++i<=NF;){ ...
Try...

awk -F"[][]" '{for(i=0;++i<=NF;){
if(i%2==0){
printf "[";print $i >> "words";printf "]"}
else{printf $i}
}{printf "\n"}
}' infile
3,914
Posted By Scrutinizer
You can follow Franklin52's solution by: cat...
You can follow Franklin52's solution by:
cat words >> newfile
to append the contents of words to newfile...
3,914
Posted By Franklin52
2 in 1, the output with the words goes to the...
2 in 1, the output with the words goes to the file "words" and the output without the words goes to "newfile":
awk -F"[][]" '{print $2 > "words"}{$2="[ ]"}1' file > newfile
3,914
Posted By kurumi
$ cat file 1. If the boss's son had been...
$ cat file
1. If the boss's son had been [kidnapped], someone would have asked for [ money ]by now.
2. Look, I haven't [committed] a crime, so why can't [ you ] let me go?

$ ruby...
3,914
Posted By rdcwayx
Here is a simple command to get the word in [ ],...
Here is a simple command to get the word in [ ], if you don't care of the format.

grep -o "\[.*\]" infile
[kidnapped]
[committed]


replace the content in [] with a blank space.

sed...
3,914
Posted By jostber
Here is a suggestion: sed...
Here is a suggestion:

sed 's/.*\[\(.*\)\].*/\1/g' sent.txt
sed 's/\(.*\[\).*\(\].*\)/\1\2/g' sent.txt
2,351
Posted By malikshahid85
for line numbers you should use sed...
for line numbers you should use


sed 's/[^0-9]//g' filename |grep -n "[0-9]"
2,351
Posted By ungalnanban
try with grep -o option. see the below example:...
try with grep -o option.
see the below example:

grep -o "[0-9]" file name
2,351
Posted By bartus11
I think in your sample, the result should be...
I think in your sample, the result should be "1001". Anyway try this: perl -ne '@m=m/\d/g;print $. ." ";print @m;print "\n"' file
16,859
Posted By Perderabo
Prepend a random number to each line, sort the...
Prepend a random number to each line, sort the file, take the first few lines, and remove the leading random number.

awk 'BEGIN {srand()} {printf "%05.0f %s \n",rand()*99999, $0; }' datafile |...
Showing results 1 to 23 of 23

 
All times are GMT -4. The time now is 09:20 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy