Programming :: Bash Read Input Word For Word ?

May 4, 2010

I am pretty new to bash scripting...I am trying to write a script that will take an input and read it word for word and then DO something with it like echo. I have been able to find how to read word for word from a file but I don't know how to do it with input.

I was looking for something like

Code:

exit 0 The input would be A-Z a-z 0-9 and have a single space between each word.

View 2 Replies


ADVERTISEMENT

Programming :: Bash Shell Script Read File Word By Word?

Jan 21, 2011

I have a output file look like this:
{"test1" : "test2", "test3" : "test4"},

How can I read word by word in each line?This is not working code:

a=0
while read word
do a=$(($a+1));

[code]...

View 14 Replies View Related

Programming :: Read Two Files Word By Word At A Time Using Any Loop By Shell Script?

Mar 4, 2010

Well, I am facing one issue:How can i read two files word by word at a time using any loop as i need word by word comparision in shell script?Please let me know pseudo code.

View 14 Replies View Related

General :: Write A Bash Script That Will Read The Word From The Text File?

Jun 10, 2011

I have a text file that contains a single word and I want to write a bash script that will read the word from the text file... The following is my incorrect attempt, as it assigns the name of the textfile to the variable as opposed to the word stored within the textfile:(assume I have a text file value.txt that has its contents a single word, say wordone)

Code:
#!/bin/sh
for f in value.txt
do
echo $f
done

so the output of the above script is value.txt, however I want it to be wordone.to summarise: how do I assign the value of the word contained within a textfile to a variable?

View 1 Replies View Related

Programming :: Bash Script - Grepped A Log File To Obtain Every Line That Contains A Word

Dec 8, 2010

I have grepped a log file to obtain every line that contains a word (let's call it 'blah'). I now want to only display a list of entries within that search result that feature the word 'host' anywhere in the line, and I also want to display the single word *after* 'host' (up until the next space). So, the end result will look like this:

[Code]....

View 8 Replies View Related

General :: Search Word And Delete Only The Word And The Line Using Sed Command?

Jun 28, 2011

Want to search for ~ and delete it as well as to append the entire line to the above line. For Ex:

1111xxxx date Sandy area is ~around this area.3222xxx date There seems to ~left side of map, the colours are accurate (showing green areas)Even if I ~zoom in, the green parks, xxx3258 date The dammed up
~away, the "other" body of water varies ~blackNatural gas leaching.

IT MUST LOOK LIKE:

1111xxxx date Sandy area is around this area. 3222xxx date There seems to left side of map, the colours are accurate (showing green areas)Even if I zoom in, the green parks, xxx3258 date The dammed up away, the "other" body of water varies blackNatural gas leaching.

View 4 Replies View Related

General :: Sed Append Word At End Of Line If Word Is Missing

Feb 19, 2010

I have to modify formsweb.cfg file in Oracle IAS.

Problem description

In formsweb.cfg file are two lines with labels archive_jini= and archive= at the beginning of line. After equal sign (=) is row of filenames of java archives delimited by coma(,). When I insert a new jar file in java directory, I have to append the very same name of jar file to both lines if that name is not yet present.

Example snippet from formsweb.cfg

View 2 Replies View Related

Programming :: Read Multiple Input With Bash?

May 7, 2010

As I'm starting to learn bash scripting I'm trying to automatize some tasks I usually perform. I have a notification mail I need to send several times a day. It has this structure:

Quote:

Dear user,
blah blah blah blah

You need to contact the following people:

[code]...

To replace "user", I found this:

Code:

read -p "Please enter username: " username
echo "Dear $username,"

Which probe to be very useful with other simple notifications like this. But I don't know how to manage the email addresses as they are usually more than one and could vary from 1 to 10. They should appear one above the other. I found this: "Here is a little work around. The only thing the user needs to do is hit enter without anything else on a line and it will close out"

Code:

#!/usr/bin/ksh
word=a
until [[ $word = "" ]];do

[code]....

I tried to use it and modify for my needs but I failed, I don't realize yet how can I use it. If possible, I would like to use the until loop like the above example just for learning purposes but any other form will be accepted as well.

View 10 Replies View Related

General :: Word Search In Files Using Bash?

Oct 9, 2010

I'm trying to use Bash to search some directories for a word in one of documents. I've tried:

Code:

$ grep -R Brzeninski /media/disk-1/Dual_Data/

but It never returned a prompt, and i'm not sure what grep means or does.

View 1 Replies View Related

General :: How To Go Back Or Forward A Word In Bash Environment

Mar 3, 2010

How can I move around the bash commandline efficiently?In the Windows prompt, one can go back or forward one word by pressing ctrl and <-/->.What's the equivalent in a bash environment?

View 1 Replies View Related

General :: Bash: Replace All Occurrences Of A Word In The Last Command

Mar 9, 2011

Almost by mistake, I figured out you could do something like:

$ cp foo.data bar1.data
$ ^bar1^bar2

And that runs the same command with bar2.data instead of bar1.data. Now, how about if I have multiple occurrences of the target word? For example:

$ cp foo.data bar.data
$ ^data^index

It only replaces the first data extension. How do I get it to replace both?

View 1 Replies View Related

OpenSUSE :: Htdig Error: Unable To Read Word Database File

Oct 13, 2010

I built the indexes, but when I search I get this: Top-Level Documentation Application Manuals

openSUSE Documentation (en)
Htdig error: Unable to read word database file '/home/philip/.kde4/share/apps/khelpcenter/index//opensuse-manuals_en.words.db'

[code]...

the UNIX manual pages work, the Application Manuals show nothing, and the openSUSE Documentation shows the same error. This is the same no matter what I search for.

View 9 Replies View Related

Programming :: Bash - Read User Input: URLs Without The Enter Key Stroke?

Sep 23, 2010

Here's a challenge I've been struggling for months with:

I have a bash script that reads URL addresses of our internal server and then executes some test commands on them. Something like this:

Code:
read -p "Enter URL: " url
sh execute-what-ever-to $url

After copy-pasting the URL the user taps the enter key and the script proceeds, but here comes the tricky part: I want this to work without the need to press the enter key after copy-pasting the URL.

"read -n" does not work in this case, as the URLs vary greatly in length. However, the URLs always end to the same string. They could be like "http://url1/END", "http://url2/END" and so on. So this ending string "END" could be theoretically used to recognize that the whole URL has been pasted.

View 2 Replies View Related

General :: Next Word Of A Particular Word ?

Feb 9, 2011

In linux is there a way to find the next word of a particular word of a file. grep displays entire line of the particular word. But i want only the exact next word of that particular word.is there any command for that.

View 13 Replies View Related

General :: Replacing Word Occurrence With An Increasing Number In A File Using Bash?

Aug 2, 2010

I have a file in the form below, and wish to replace each start line with an increasing number. So instead of:

Code:
start
content content
start
content content
start

[Code]....

After several searches and a bit of messing around, it's clear I'm missing something, so was wondering if anyone could offer any insight?

View 17 Replies View Related

Software :: Fvwm Resize Throws Off Xterm (bash) Word Wrapping

Aug 27, 2010

when I resize an xterm in fvwm, bash word wrapping is messed up. I don't know if it's from running a program that uses curses or not.

View 1 Replies View Related

OpenSUSE Install :: Arial-KOI Type, The "è" Word Is Replaced By A "X" Word?

Aug 3, 2011

Found a font bug: in the Arial-KOI type, the "è" word is replaced by a "X" word...

View 3 Replies View Related

Programming :: Deleting Lines Above And Below A Word

Mar 25, 2011

i jst want to delete a host entry from httpd.conf the entry for lal.com should be deleted!!

View 14 Replies View Related

Programming :: How To Implement Count Word

Nov 9, 2010

I have these but not working.

size_t count_words(const std::string& s)
{
std::istringstream is(s);
return distance( std::istream_iterator<std::string>(is),
std::istream_iterator<std::string>());
}
and
std::string s; // word count
unsigned int wordno = 0;
while(getline(myfile, s))
{ ++wordno;
if(s.empty())++ wordno;
else wordno += count_words(s);
std::cout << s << '
';
}

myoutput1<< "Number of words : " << wordno << '
';
myoutput1 << "
Word" <<" " <<" Occurrence" <<endl;
myoutput2<< "Number of words : " << wordno << '
';
myoutput2 << "
Word" <<" " <<" Occurrence" <<endl;

View 6 Replies View Related

Programming :: Check Command Line For A Word?

May 23, 2010

I'm building a script for my place of employment. The next step in it is checking what the user input was. Determining if they added a part in there or not. The script prompts for a hostname. Hostnames are localhost.localdomain. Now, I want the script to check to see if they put localdomain and if they did, not to add the domain to the /etc/sysconfig/network, but just what they entered. So say the user inputs:

[Code]....

View 4 Replies View Related

Programming :: Check For Word Frequency In 1 Column

Jul 6, 2010

I have a large tab delimited text file, about 17gb. It only has 6 column. On column number 4, it is all numbers. Ranging from 1-1000. I want to count how many times each number occured. So the output I want is in 2 columns, first one is a number, second column is how many times it occured. I tried

head -n 1000 coverage | cut -f 4 | uniq -c

Didn't work for me, the first column returned is not unique.

View 3 Replies View Related

Programming :: Find A Word From Different Files In System?

Dec 22, 2010

How to find a word from different files in linux ?
Is there any command like (find . / -name *****), that can search files in the system for a particular word in Linux?

View 5 Replies View Related

Programming :: Append Numbers To A Word List?

Dec 30, 2010

If I do:

for i in $(cat names); do seq -f "$i%03.0f" 0 999; done > output5.txt

I got ( tail snipped):

997munt
998munt
999munt

If I do:

for i in $(cat names); do seq -f "%03.0f$i" 0 999; done > output4.txt

I got:

997Zygmunt
998Zygmunt
999Zygmunt

How I can get numbers from 000 to 999 appended like:

Zygmunt997
Zygmunt998
Zygmunt999

View 8 Replies View Related

Programming ::Word Count For All Files In A Directory?

Apr 7, 2011

Word Count for all files in a directory

View 1 Replies View Related

Programming :: Capitalise Only First Letter Of Each Word In A Sentence?

Feb 13, 2009

ive searched around about this for a bit, but have been unable to find a working and suitable solution for me to do, what i require is to be able to change a string such as:hIs Is a TeSt to --> This Is A Test - AND place it in a variable - so far ive only succesfully been able to make the whole sentence uppercase or lowercase.

View 2 Replies View Related

Programming :: Creating A List Of Word Using Tr Command

Jul 11, 2010

I have a file having name test.txt content of which is following My Self is Arvind Kumar.My Date of Birth is 21/07/1984.I am 26 year year old.I did M.Sc Informatics from Delhi University in 2008.I did B.Sc Electronics from Acharya narendra Dev college Delhi University.I did my schooling from DAV Yusuf sarai.Curren tly I am working with InterGolbe Technologies as a Associate software Engineer.I want to be Linux Expert. What I am doing I am creating a list of words,But i want to take B.Sc and M.Sc as a single word

[Code]....

View 5 Replies View Related

Programming :: Popup A Box On A Webpage When A Particular Word Is Mouseovered On?

Apr 2, 2010

Just like ContentLink here on LQ itself, how do I popup a little box or something like that, when a particular word is mouseovered on?

View 3 Replies View Related

Programming :: Get Files With Word 'hosts' In Middle?

Nov 18, 2010

I have this statement which greps .csv files. Code:my @files=grep {$_ =~ /.csv/}What about if I needed to get files with the word 'hosts' in the middle?

View 2 Replies View Related

Programming :: Printing A Specific Word Out Of A File?

Jan 6, 2011

so i have a file that has the following

file1.txt
ID1 age_11 dog_n3 parent_dog_n1
ID1 age_7 dog_n4 parent_dog_n3
ID1 dog_n5 age_4
ID1 dog_n6 age_4

[Code].....

As you can see i would like the output file to be just the dogs, not the otehr information. But because the information is mixed up how can i extract only the dogs? (i cant do and awk '{print }' because the dogs are found in colounm 2 or 3 or sometimes even 4.

View 9 Replies View Related

Programming :: Remove Exact Matching Word Using Sed?

Aug 18, 2009

I have a file which has the words "splashimage and "splash". I would like to remove the word only "splash" from everywhere.

Using the following command code...

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved