Ubuntu :: Find And Replace With Sed At Beginning Of A Word

Nov 15, 2010

I want to write a small script to rename a bunch of files. Their name is of the form 'long number'|'name'|'extension', for example:

52354Football_part2.flv
2353452Nice_weather_4_ducks.flv

I would like to rename these to:

Football_part2.flv
Nice_weather_4_ducks.flv

If in my script I use something like

Code:
sed s/[0-9]//g
on each file, I will get
Football_part.flv, instead of Football_part2.flv,
and
Nice_weather__ducks.flv, instead of Nice_weather_4_ducks.flv.

how to instruct sed to only remove numbers that are in the beginning of the name in a simple way?

View 2 Replies


ADVERTISEMENT

General :: Replace Function Replace More Than One Word With The Same Character(s)?

Apr 23, 2011

Can the Replace function replace more than one word with the same character(s)?

Also, do you know how to access the plugins provided by the gedit-plugins package?

View 3 Replies View Related

General :: Erasing From The Cursor Up To The Beginning Of The Following Word In Vim

Dec 13, 2010

In a wide family of "ancient" text editors, by pressing ^T you erased from the cursor up to the beginning of the following word. If we use '_' to represent the cursor, the thing was like this:

Code:

If I now hold <CNTL> down and press <T>, the result will be

Code:

Want to feel at home with vim. Many times I have consulted and even tried to systematically study vim's man page. Sometimes I consulted it with profit, sometimes not. This is one of the latter.

View 6 Replies View Related

General :: Erasing From The Cursor Up To The Beginning Of The Word In Vim?

Dec 13, 2010

In a wide family of "ancient" text editors, by pressing ^T you erased from the cursor up to the beginning of the following word. If we use '_' to represent the cursor, the thing was like this:

Code:
want to feel _ at home with vim. If I now hold <CNTL> down and press <T>, the result will be Code: want to feel at home with vim. Many times I have consulted and even tried to systematically study vim's man page. Sometimes I consulted it with profit, sometimes not. This is one of the latter.

View 3 Replies View Related

Programming :: Sed - Replace All Spaces At Beginning Of Line With The Number 1?

Jun 21, 2010

Does any one know what syntax i could use to allow me to replace all instances at the beginning of a line with ones.

Before :

Code:
----------------------------------------------------------------------
Logical device information
----------------------------------------------------------------------
Logical device number 0
Logical device name : RAID1Mirror
RAID level : 1
Status of logical device : Optimal

After

Code:
----------------------------------------------------------------------
Logical device information
----------------------------------------------------------------------
Logical device number 0
111Logical device name : RAID1Mirror
1111RAID level : 1
11111Status of logical device : Optimal

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

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

General :: Find/grep/wc Command To Find Matching Files - Print Filename And Word Count?

Sep 11, 2009

I am trying to do a find/grep/wc command to find matching files, print the filename and then the word count of a specific pattern per file. Here is my best (non-working) attempt so far:

wc `find . ( -name "*.as" -o -name "*.mxml" ) -exec grep -H HeightResizableList {}` ;

View 10 Replies View Related

General :: Sed Command - Find Line Not Beginning With Double Quote

Mar 15, 2011

I need to find each line in a file which does NOT begin with a double quote (") and append that line to the previous line. I have been successful doing this using the following command:
cat filname.csv | sed -e :a -e '$!Ns/
[^"]//;ta -e 'P;D' > newfilename.csv

My issue is the substitution. As you would expect after the line is appended to the previous line the first character is removed. I need it to not be removed. I tried:
cat filname.csv | sed -e :a -e '$!Ns/
[^"]/&/;ta -e 'P;D' > newfilename.csv
but it just hangs.

Goal:
Input:
"line 1"
line 2
Output with existing sed command is:
line 1ine2
I need it to be line1line2.

View 9 Replies View Related

Ubuntu :: Find Word Print Out # Of Lines

Feb 17, 2010

this is driving me crazy. How can i in the terminal, display only the first 5 lines of say dmesg

View 7 Replies View Related

Ubuntu :: Script To Find Vowel Word (Alphabetic)

Apr 14, 2011

I am writing a script to find words in a file call vowel words that have 5 or more vowels and then sort them alphabetic, this should be done using grep.

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

General :: Recursively Find A .doc File That Contains A Specific Word?

Aug 31, 2011

I'm using bash under Ubuntu.Currently this works well for the current directory:catdoc *.doc | grep "specificword" But I have lots of subdirectories with .doc files.How can I search for, let's say, "specificword" recursively?

View 2 Replies View Related

General :: Find A Phrase/word Recursivly In A File Tree?

Aug 31, 2010

how do I find a phrase/word recursively in a file tree in Linux?I tried find . -name ./* | grep my_phraseand I tried grep -r "register_long_arrays" *

View 5 Replies View Related

General :: Command To Find A Specific Word In Directories And Subdirectories?

Jun 7, 2010

tell me the command used to find a specific word in directories and sub-directories in linux?

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

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

Ubuntu :: Vim Find/replace Command Using Wildcards?

Aug 1, 2010

I'm struggling with the Vim find/replace command using wildcards.

I have several, big html files with lots of instances of: <p stuffiwanttoremove>

I've been trying the Vim command: %s/<p *>/<p>/ge

but it doesn't seem to work.

Does anybody know what I'm doing wrong?

I realise there may be alternatives to this (eg a bash script)

View 2 Replies View Related

General :: Find Or Replace Without Using Sed?

Dec 27, 2010

I am working on writing a script for find and replace a string using sed.But know I want to write without using sed.

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

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

Ubuntu :: Gedit Wildcards In Find / Replace Feature

Feb 27, 2010

I am cleaning up some text files to put on a website and am using the find/replace feature of Gedit extensively. The only problem I am having is that I can't find a way to use wildcards. For instance, I want to use the "?" and "*" in the same or similar way you do in bash. I already know that:

Represents a carriage return, and that is great, but I want to do something like: "?." to replace "A.", "B.", "1.", "2." with just plain spaces. The document in question is written in narrative, but has a bunch of outline markers in it, and I want to remove the outline markers.

I tried "escaping" the characters in a similar way as by using "?.", but that didn't work. Google was not very fruitful, and the Gedit help seems to be Gnome help and includes all kinds of useless info (for my problem) about wildcards in other programs.

View 2 Replies View Related

General :: Find And Replace String?

Jul 26, 2011

I need to find this "TYPE=MyISAM;" and replace with "ENGINE=MyISAM;" in all .sql files in a directory. How can I do this with sed?

View 2 Replies View Related

General :: Sed Find And Replace With Wildcard?

Aug 5, 2011

I would like help with modifying the following content:

toolbox/perl/man/man3/ExtUtils::Command.3::Command.3 differ
toolbox/perl/man/man3/ExtUtils::Command::MM.3::Command::MM.3 differ
I would like the content to be changed to:
toolbox/perl/man/man3/ExtUtils::Command.3
toolbox/perl/man/man3/ExtUtils::Command::MM.3

I was not sure how to tell sed what to look for? I tried the following but it did not work. sed -i 's/::* differ//g' mandiff.log

View 3 Replies View Related

Software :: How To Find And Replace On All Backslashes

Feb 8, 2010

I'm in the middle of a data migration project and I have a text file where the data in one of the fields contains a "" at the end of each line. I know how to do a find and replace on ALL backslashes using something like this:
Code:
:%s/\//g
The above example would replace all backslashes with nothing, effectively "removing" them. Does anyone know how I can apply a similar function that only removes the backslashes that exist at the end of a line?

View 3 Replies View Related

Ubuntu :: Bash Command To Find And Replace Text In File

Apr 3, 2010

I'm having problems with Tomboy. I have a few hundred note files and I need to go through all of them and replace all instances of "<link:broken>a</link:broken>" with "a". Is there a bash command I can use to do this?

View 2 Replies View Related

General :: Find And Replace Command For Whole Directory

Aug 17, 2011

Is there any command in Linux which will find a particular word in all the files in a given directory and the folders below and replace it with a new word?

View 4 Replies View Related

Programming :: Find And Replace Script In Bash?

Sep 28, 2010

Im looking for assistance to create a script to find and replace files.Probably best if I give you the background Our server uses a specific application which stores user data, each user data account (a folder on the server) has a file called 'Profile.xml' this file gets updated and replaced about every 30 mins similar to the fashion logrotate works i.e. Profile.xml.1 Profile.xml.2 -> .10

What we experience is that if the application crashes unexpectedly while it is doing its user profile refresh task we end up with sometimes a few hundred Profile.xml files which end up 0kb(should be around 4kb) , and our server see's these as corrupted profiles and will not see them. Our fix is to go back thru and rename the Profile.xml.1 to be Profile.xml (or sometimes up to Profile.xml.5 to Profile.xml) We want a script we can manually run to automate this process The server tree is

/mnt/array1/username/db/Profile.xml
/mnt/array2/username/db/Profile.xml
etc
etc

What we have so far is a script which finds the affected files

find /mnt/ -maxdepth 4 -name Profile.xml -size -1k

This will display a list of affected profiles, and we can append it to a text file with >>output.txt on the end.

if 'pattern' in 'location' equals '0kb' then 'cp' Profile.xml.1 Profile.xml

View 4 Replies View Related

General :: Find And Replace Text From Many Files In A Dir?

Jul 8, 2010

I have a many directories each with about 20 html files inside. All the files have .html ext. What I'm hoping is possible is from command line to find some text in each one and replace it with some other text.

Basically what I want to replace is;

/awstats/
with
awstats/

I can do this easily with dreamweaver or some other application but because I have 960 pages total to do I'm hoping to do it this way.

View 6 Replies View Related







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