Search Results

Search: Posts Made By: martinsmith
1,541
Posted By Peasant
Try this : while read word; do i=$((i+1)) ...
Try this :

while read word; do
i=$((i+1))
convert canvas.jpg \
\( -size 350x350 -background none \
-fill white -gravity center caption:"$word" -trim +repage -depth 8 \) \
-gravity center...
1,223
Posted By Scrutinizer
With GNU sed, try: sed 's/Remove This:...
With GNU sed, try:
sed 's/Remove This: [0-9,]*/\t/' file

with regular sed you need to use a real TAB character, which can be entered with CTRL-V TAB
sed 's/Remove This: [0-9,]*/ /' file
...
1,223
Posted By rbatte1
Hello martinsmith, I have a few to questions...
Hello martinsmith,

I have a few to questions pose in response first:-
Is this homework/assignment? There are specific forums for these.
What have you tried so far?
What output/errors do you...
2,063
Posted By Don Cragun
Will your input ever contain the string...
Will your input ever contain the string title=">PATTERN1 without a matching string PATTERN2 on the same line, such as one of the following?:
title=">PATTERN1 Tokyo City whatever whatever...
2,063
Posted By Don Cragun
And, in those cases, what is supposed to happen? ...
And, in those cases, what is supposed to happen? Does capitalization start with the first string and continue until the second string is seen on a subsequent line, or is capitalization only...
2,063
Posted By Aia
Would any of these do it? perl -ple '$cl=$_;...
Would any of these do it?
perl -ple '$cl=$_; while(/title=">PATTERN1\s+(.*?)\s+PATTERN2/g){$opt=$mpt=$&; $os=$ms=$1; $ms=~s/\b(\w)/\U$1/g; $mpt=~s/$os/$ms/; $cl=~s/$opt/$mpt/}$_=$cl' patterns.file
...
2,063
Posted By RavinderSingh13
Hello martinsmith, Following awk solution...
Hello martinsmith,

Following awk solution may help you too in same, let me know if this helps.

awk '/^title=\">PATTERN1.*PATTERN2$/{A=$1;for(i=2;i<NF;i++){A=A OFS toupper(substr($i,1,1))...
2,063
Posted By Aia
cat patterns.file blank">PATTERN1 some word...
cat patterns.file
blank">PATTERN1 some word PATTERN2
title=">PATTERN1 some word PATTERN2
blank">PATTERN1 another word PATTERN2
title=">PATTERN1 another word PATTERN2 and leave this alone PATTERN2...
21,058
Posted By Don Cragun
Try: sed 's/ / - /2' file Note that this also...
Try:
sed 's/ / - /2' file
Note that this also leaves lines that don't have two <space> characters in them unmodified.
21,058
Posted By RavinderSingh13
Hello bhupeshchavan, Adding an awk solution...
Hello bhupeshchavan,

Adding an awk solution for same now too.

awk '{$2=$2 FS "-"} 1' Input_file
If you need to remove any empty lines from Input_file then following may help you in same.
...
7,601
Posted By MadeInGermany
Aia, your solution does not work. First, there is...
Aia, your solution does not work. First, there is a g too many. Second, the \b is not replicated to the \1. But even if I improve it like
perl -ne 'print unless /\b(\w+)\b.*\b\1\b/i'...
7,601
Posted By Aia
cat martinsmith.file One and a Two Unix.com...
cat martinsmith.file
One and a Two
Unix.com is the Best
This as a Line Line
Example will be the same that EXAMPLE
Example duplicate sentence with the word duplicate

perl -ne 'print unless...
7,601
Posted By MadeInGermany
Best of breed awk '{split("",A); for(i=1;...
Best of breed
awk '{split("",A); for(i=1; i<=NF; i++) if (A[tolower($i)]++) next} 1' file
(Just seeing Scrutinizer has it already)
7,601
Posted By Scrutinizer
Note: delete A is BSD awk and GNU awk...
Note:

delete A is BSD awk and GNU awk only. With regular awks use for(i in A) delete A[i] or split("",A)
length(A) is GNU sed only, with regular awk, use a counter..


--
So POSIX awk...
7,601
Posted By RudiC
I like that approach. Somewhat abbreviated:awk...
I like that approach. Somewhat abbreviated:awk '{delete A; for(i=1; i<=NF; i++) if (++A[tolower($i)] > 1) next} 1' file
One and a Two
Unix.com is the Best
7,601
Posted By MadeInGermany
Interesting solution. In short it is awk...
Interesting solution. In short it is
awk '{for(i=1; i<=NF; i++) A[tolower($i)]} (NF==length(A)); {delete A}'
But works only with a recent GNU awk.
Other awk versions say "fatal: attempt to use...
7,601
Posted By RavinderSingh13
Hello martinsmith, Adding one more solution...
Hello martinsmith,

Adding one more solution here without 2 time loops, which may help you here. Let's say following is the Input_file.

One and a Two
Unix.com is the Best
This as a Line Line...
7,601
Posted By Scrutinizer
Adapting RudiC's suggestion for case independence...
Adapting RudiC's suggestion for case independence and minimum string length:
awk '{for (i=1; i<NF; i++) for (j=i+1; j<=NF; j++) if ((tolower($i) == tolower($j)) && length($i)>=3) next}1' file

...
7,601
Posted By RavinderSingh13
Hello martinsmith, Could you please try this...
Hello martinsmith,

Could you please try this and let me know if this helps. I am ignoring case sensitivity here so it will match all kind of same words either they are in capital or small letters....
7,601
Posted By RudiC
From what length is a "string" a string? Is "a" a...
From what length is a "string" a string? Is "a" a string?

---------- Post updated at 11:40 ---------- Previous update was at 11:40 ----------

Does case matter?

---------- Post updated at...
21,058
Posted By RavinderSingh13
Your Welcome, also if you have blank lines too...
Your Welcome, also if you have blank lines too into your Input_file and you want to leave them as it is, then following may help you. Let's say following is the Input_file:

First line of text...
21,058
Posted By Don Cragun
Assuming that there is at least one space (or two...
Assuming that there is at least one space (or two words) on each line, you could also try the simpler:
sed 's/ / - /' file
21,058
Posted By RavinderSingh13
Hello martinsmith, Could you please try...
Hello martinsmith,

Could you please try following and let me know if this helps you.

awk '{$2="-" OFS $2} 1' Input_file
Output will be as follows.

First - line of text
Second - line of...
3,801
Posted By Don Cragun
You could also try: sed 'sX \([^ ]*\)/\1X...
You could also try:
sed 'sX \([^ ]*\)/\1X \1/Xg' file
3,801
Posted By Aia
Please, try: perl -pe 's:(folder\d+)/\1:$1/:g'...
Please, try:
perl -pe 's:(folder\d+)/\1:$1/:g' martinsmith.file
some text here folder1/ some text here folder1/ some text here folder1/ some text here
some text here folder2/ some text here...
Showing results 1 to 25 of 34

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