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


ADVERTISEMENT

General :: Counting The Occurrence Of A Word In A Collection Of Files?

Jun 16, 2010

I am trying to find the word count of a specific word in a collection of documents, in Linux.

I have tried with grep and ack-grep in combination with wc but I can't seem to come up with a valid combination of pipes :)

View 1 Replies View Related

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

General :: Change All Number 10 In A Text File To Word Form?

Mar 20, 2011

I need to change all number 10 in a text file to word form, or in short from 10->ten. the thing is number 10 including in dates such as 10/22/1997 or 03-10-2011 should not be changed. im having some trouble because the file contains numbers like "price range from 10-50k".

this is just a sample.

name: john smith
birthday: 10-11-1995
date hired: 05/10/2010
expected salary: 10-50k
typing speed: 10 wpm

[Code].....

Using sed command is it possible to change like this..

View 11 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 :: Count The Number Of Occurrence Characters In A String ?

Jan 26, 2011

How do I count the number of occurrence characters in a string in an efficeint way ?

How do I reverse the words in a string with out using temp variables if possible . (if not possible use temp variables ?

Why do I specify dependedcies for header files in the Makefile ?

View 2 Replies View Related

General :: Use Sed To Replace Number That Is In A String With Word?

Sep 12, 2010

I am trying to replace the first number in a string at the end of the line with the word that matches that number. for example i want to replace 546215 to be five-46215. The command that I have tried is

sed -r 's/5[0-9]{5}$/five-[0-9]{5}/'

View 3 Replies View Related

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 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

Software :: Eth-number Is Increasing By One When Every Reboot?

Feb 23, 2010

When every reboot, the eth number is increasing one, such as eth1 becomes eth2,...

I have deleted the 75-persistent-net-generator.rules in the ubuntu 9.10 PC

but In the file 70-persistent-net.rules, the eth number is still increasing by one when every reboot?

View 1 Replies View Related

General :: Replacing Empty Values In Bash?

Mar 11, 2011

I'm executing the below bash script, but when the m variable doesn't get any value it becomes empty. I don't want that.

Code:
for i in "$@"
do
m=$(grep TOTAL_MAPS $i | awk '{ print $2}');
totalmaps+="<string>"$m"</string>"

[Code]....

View 6 Replies View Related

Ubuntu :: Increasing Maximum Number Of Applications In Browser?

Dec 28, 2010

I just installed maverick on my son's netbook, and so far we like the new unity interface. The main issue is that there seems to be a maximum number of apps that can be listed under any particular category in the applications browser. So for instance when he goes to his "Games" category, it only lists applications up through S (he has a lot of games installed).

So far I haven't found a settings panel for unity. There has to be a way to bump up the maximum.

View 1 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

Programming :: Replace 2nd Occurrence Of A String In A File - Sed Or Awk?

Apr 5, 2010

I know how to replace a particular instance (say 3rd one) of a word in a line using sed based on the sed one-liners. However I would like to replace a particular instance of a word in the entire file.

For example, here is a file:

Code:
John
Betty
Jack
Ron
Jack
Paul

So now I would like to replace the second instance of Jack (in red color) with "Rob" (for example). Not quite sure how to do that? I tried couple of things from here but they did not work.

View 10 Replies View Related

General :: Rename A File By Replacing Specific Letters In The File?

May 11, 2010

I used a script that renamed my file eg 'echo webutil.olb | tr [A-Z] [a-z]' i wanted to rename it back to webutil.olb. How do i do this for many other files that i have

View 3 Replies View Related

General :: Replacing A String In A File With The Contents Of Another File?

Jun 15, 2010

I would like to know how I can replace a string in one file with the complete contents of another life.

View 10 Replies View Related

General :: Increasing Capacity To File Server Through Storage Manager

May 10, 2011

My requirement. We have a linux File server which was connected to SAN (IBM DS4700)now I need to increase my capacity by 50GB I've added the 50GB through the IBM storage manager to the File server, but it doesn't showing on my linux file server

bellow the detail of my drives
/dev/mapper/mpath0p6 1.6G 287M 1.2G 20% /
/dev/mapper/mpath0p7 837M 240M 554M 31% /var
/dev/mapper/mpath0p3 4.1G 2.5G 1.4G 65% /usr
/dev/mapper/mpath0p2 5.1G 1.7G 3.2G 36% /home
/dev/mapper/mpath0p1 200M 24M 166M 13% /boot
tmpfs 2.1G 0 2.1G 0% /dev/shm
/dev/mapper/mpath0p8 356G 303G 36G 90% /filesrv

I need to add the 50GB on to the "mpath0p8".

View 2 Replies View Related

General :: Bash Scripting - Grab First And Last Number?

Jan 13, 2011

I'm trying to get an output of a file in numeric order. Basically I need the starting number and the ending number in sed this into anther file. The test2.lis file I'm just awk'ing for the first row and if its out of order put it in order so I can grab the first and last numbers. I'm sure I can do this all in an array. The first sed command gets rid of blank lines and outputs it to a file. Then I head and tail for the first and last number then I want to sed those numbers into a file that exsist.

[code]...

The error I get is:

sed: -e expression #1, char 24: unterminated `s' command.

View 13 Replies View Related

General :: Extract Only Number In A Path In Bash?

Mar 17, 2011

I've these path:

Code:
xxx/yyy/zzz/0908/aaa/a.txt
xxx/yyy/zzz/0909/aaa/a.txt
xxx/yyy/zzz/0910/aaa/a.txt
fff/ggg/hhh/iii/jjj/0911/aaa/a.txt
fff/ggg/hhh/kkk/0912/aaa/a.txt

and I would like to extract only the number, so that I've get the result

Code:
0908
0909
0910
0911
0911

How can I do it in bash?

View 1 Replies View Related

General :: Replacing Text In A File?

Jul 26, 2010

how to replace following text in the file name.cfg ?I need to replace

name:=inet.hr=>1|inet.hr=>1
with
name:=none
I am using
sed -i 's/name:=inet.hr=>1|inet.hr=>1/name:=none/g' name.cfg

View 4 Replies View Related

General :: Breaking Iteration After A Given Number Of Iterations (bash)?

Jun 14, 2011

Take this block of pseudocode:

Code:
for i in $list; do
<some statements>
if i > 5
exit
<more statements>
done

That is, want to terminate the iteration just after 5 iterations. A first problem, is that list is a string and not a number. It's all I can say, except to keep reading bash monster manual.

View 8 Replies View Related

Programming :: Bash: Printing The Line Number In Bash Script?

Feb 4, 2011

I would like to know how do I print the line # in a script. My requirement is, I have a script which is about ~5000 lines long. If there are any errors happen I just exit. And I would like to add the line # of the script where the error happened.

View 3 Replies View Related

General :: Increasing Screen Resolution To 1024x800 In Ubuntu - No Xorg.conf File?

Mar 2, 2011

I have set up my Ubuntu virtual machine and am trying to adjust the screen resolution because it's stuck at 800x600 presently and there are no higher resolution options. I've looked at numerous similar forms and tutorials online and they all seem to involve editing /etc/X11/xorg.conf. However, for whatever reason, this file seems not to exist on my machine. I found another tutorial on how to add a screen resolution using xrandr --addmode which added the resolution I want to the list that appears when I type the command xrandr, but when I try to apply it I get an error about CRTC 262 failing.

View 8 Replies View Related

General :: Replacing The Text In Same File Using SED Command?

Oct 11, 2010

I have a String like "A.words=Ajay,Anil" in file A.And it contains a lot of other information also. I wanted to replace "Ajay,Anil" with "Vijay,Vinay" with sed command with using existing file only(not using another file)

View 9 Replies View Related

General :: How To Add Word At The End Of File

Sep 13, 2010

I'm trying to add a word at the end of a file that already contains data. I need to do it using a single command without human interaction cause it's gonna be part of an automatic script.

View 2 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

Programming :: Replacing Numbers In Bash Scripts?

May 25, 2010

I have lines in some files that look exactly as below, and the line numbers they occur in are always the same. (Lines 136-139)

W 0.00000000 0.00000000 2.00000000
W 0.50000000 0.50000000 2.50000000
W 0.00000000 0.00000000 3.00000000

[code]...

View 1 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







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