words sort


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers words sort
# 1  
Old 12-02-2011
Bug words sort

hello guys
i need a command that take the words from multiple files and put them in another file this way: one word needs to appear only once in the destination file with small letters no matter how it appears in source files , the words from destination file needs to be alphabetical ordered and to be only 1 word per line
Can someone help me with this please ? or some tips pleaseSmilie
# 2  
Old 12-02-2011
Code:
awk 'BEGIN{OFS="\n"} {$0=tolower($0);$1=$1;print}' inputfilelist | sort -u > outputfile


Last edited by CarloM; 12-02-2011 at 07:41 AM..
# 3  
Old 12-02-2011
is not working.....this only copy the content of a file
# 4  
Old 12-02-2011
Code:
# cat 1.txt
A file with
some words in it
# cat 2.txt
A different file with some
other words
#  awk 'BEGIN{OFS="\n"} {$0=tolower($0);$1=$1;print}' 1.txt 2.txt | sort -u
a
different
file
in
it
other
some
with
words

If you're getting different results then you need to show what they are, what the inputs are, and what command you're actually using. Just "is not working" is not a useful description...
This User Gave Thanks to CarloM For This Post:
# 5  
Old 12-02-2011
Quote:
Originally Posted by CarloM
Code:
# cat 1.txt
A file with
some words in it
# cat 2.txt
A different file with some
other words
#  awk 'BEGIN{OFS="\n"} {$0=tolower($0);$1=$1;print}' 1.txt 2.txt | sort -u
a
different
file
in
it
other
some
with
words

If you're getting different results then you need to show what they are, what the inputs are, and what command you're actually using. Just "is not working" is not a useful description...
your command also extracts numbers... and if there is something la 10Roger it wil extract 10Roger and not just Roger
# 6  
Old 12-02-2011
Code:
cat file1 file2 ... |tr '[A-Z ]' '[a-z\n]' |sort -u

# 7  
Old 12-02-2011
Quote:
Originally Posted by g0dlik3
your command also extracts numbers... and if there is something la 10Roger it wil extract 10Roger and not just Roger
True, but then the OP didn't specify that it shouldn't...
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Replace particular words in file based on if finds another words in that line

Hi All, I need one help to replace particular words in file based on if finds another words in that file . i.e. my self is peter@king. i am staying at north sydney. we all are peter@king. How to replace peter to sham if it finds @king in any line of that file. Please help me... (8 Replies)
Discussion started by: Rajib Podder
8 Replies

2. Shell Programming and Scripting

Search words in any quote position and then change the words

hi, i need to replace all words in any quote position and then need to change the words inside the file thousand of raw. textfile data : "Ninguno","Confirma","JuicioABC" "JuicioCOMP","Recurso","JuicioABC" "JuicioDELL","Nulidad","Nosino" "Solidade","JuicioEUR","Segundo" need... (1 Reply)
Discussion started by: benjietambling
1 Replies

3. UNIX for Advanced & Expert Users

Sort words based on word count on each line

Hi Folks :) I have a .txt file with thousands of words. I'm trying to sort the lines in order based on number of words per line. Example from: word word word word word word word word word word word word word word word word to desired output: word (2 Replies)
Discussion started by: martinsmith
2 Replies

4. UNIX for Dummies Questions & Answers

Replace the words in the file to the words that user type?

Hello, I would like to change my setting in a file to the setting that user input. For example, by default it is ONBOOT=ON When user key in "YES", it would be ONBOOT=YES -------------- This code only adds in the entire user input, but didn't replace it. How do i go about... (5 Replies)
Discussion started by: malfolozy
5 Replies

5. Shell Programming and Scripting

Gawk gensub, match capital words and lowercase words

Hi I have strings like these : Vengeance mitt Men Vengeance gloves Women Quatro Windstopper Etip gloves Quatro Windstopper Etip gloves Girls Thermobite hooded jacket Thermobite Triclimate snow jacket Boys Thermobite Triclimate snow jacket and I would like to get the lower case words at... (2 Replies)
Discussion started by: louisJ
2 Replies

6. Shell Programming and Scripting

How to sort lines according words?

Hello I greped some lines from an xml file and generated a new file. but some entries are missing my table is unsorted. e.g. NAME="Adel" ADDRESS="Donaustr." NUMBER="2" POSTCODE="33333" NAME="Adel" ADDRESS="Donaustr." NUMBER="2" POSTCODE="33333" NAME="Adel" NUMBER="2" POSTCODE="33333"... (5 Replies)
Discussion started by: witchblade
5 Replies

7. Shell Programming and Scripting

How can I sort by n number is like words?

I want to sort a file with a list of words, in order of most occuring words to least occurring words as well as alphabetically. ex: file1: cat 3 cat 7 cat 1 dog 3 dog 5 dog 9 dog 1 ape 4 ape 2 I want the outcome to be: file1.sorted: dog 1 (12 Replies)
Discussion started by: castrojc
12 Replies

8. UNIX for Dummies Questions & Answers

Trying to sort words and numbers associated with them.

Hi. I have a file containing words and numbers associated with them as follows - c 2 b 5 c 5 b 6 a 10 b 16 c 18 a 19 b 21 c 27 a 28 b 33 a 76 a 115 c 199 c 251 a 567 a 1909 (4 Replies)
Discussion started by: maq
4 Replies

9. Shell Programming and Scripting

Shell script to find out words, replace them and count words

hello, i 'd like your help about a bash script which: 1. finds inside the html file (it is attached with my post) the code number of the Latest Stable Kernel, 2.finds the link which leads to the download location of the Latest Stable Kernel version, (the right link should lead to the file... (3 Replies)
Discussion started by: alex83
3 Replies

10. Shell Programming and Scripting

sort words in a line

Hi Im looking for a way, hopefully a one-liner to sort words in a line e.g "these are the words in a line" to "a are in line the these words" Thanks! (15 Replies)
Discussion started by: rebelbuttmunch
15 Replies
Login or Register to Ask a Question