General :: Replacing Dot In String But Leaving Last One?

Jan 17, 2011

Possible Duplicate: replacing dot in string, but leaving last one replace the "." [dots], but leave the last one: e.g.: .txt [there could be random number of dots in the string, even zero, i just need the last one]

$ echo 'someth.ing.something.txt' | SOMEMAGIC
someth-ing-something.txt
$

View 1 Replies


ADVERTISEMENT

General :: Replacing A Numeric String With A Sequence Of Numbers?

Jun 21, 2009

I have a text file with content that look like this..

Code:
1,3927,"AIS"
1,6928,"AIS"

[code]...

View 13 Replies View Related

Programming :: Replacing String Using Awk?

Jan 19, 2010

i have a string of information displayed in this way :

Code:
John:king:20:34:60
what i am tring to do is to read in input which is given by the user and change it to the

[code]....

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

Software :: Filter Command For Replacing A String In A Folder?

Mar 5, 2010

I am having a folder which is having 155 files, i have replace a string with a different string.How can i do it?

View 1 Replies View Related

Programming :: Replacing A String Of Text That Includes "/"

Sep 29, 2010

Suppose I have a file named temp.txt

cat temp.txt
word/one/two/three

If I would like to replace "one" with "six" I would do this:

cat temp.txt | sed 's/one/six/'
word/six/two/three

Now I want to replace "one/two" with "six/seven" and these options don't work:
cat temp.txt | sed 's/one/two/six/seven/' (OFCOURSE)
cat temp.txt | sed 's/"one/two"/"six/seven"/'

I even want to be able to replace "one/two" with "six/seven/eight"

View 6 Replies View Related

General :: Installations Leaving Behind 4 GB Swap Partitions?

Jun 21, 2011

I've installed some Linux distributions over the past few weeks, and I've recently noticed that previous installations of Linux have left my hard drive cluttered with numerous 4 GB swap partitions. I've since deleted them, but is there any way to avoid this a priori in the future?

View 12 Replies View Related

Programming :: Copy String A To String B And Change String B With Toupper() And Count The Chars?

Oct 22, 2010

copy string a to string b and change string b with toupper() and count the chars

View 3 Replies View Related

General :: Closing File While Leaving Instance Of Gedit Open

Apr 19, 2011

If a file is opened from the common prompt with something like:
gedit somefile &
Is there a way to close somefile while leaving the instance of gedit still open? My idea is that sometimes I will have more than one file open in gedit. I run a script daily that updates to a log file. The log file is then opened and viewed with gedit.

View 5 Replies View Related

General :: Replace String With Empty String Of Dir Path ?

Apr 2, 2011

I want to replace a string of directory path in a string to empty:

Code:

But this doesnt seem to give me the desired thing:

Code:

This gives the desired outcome, but its specific, i need a variable in the sed not a string. And if I replace STRING="/mnt/sda1/record/$dd/" then I cant use it for something else, cause its has all the weird backslashes now.

View 3 Replies View Related

General :: Read A Text File And Ftp Files Using Bash W/out Leaving The Ftp Prompt

Oct 9, 2009

I have a script almost working except for 1 thing. What I'm trying to do is read a file that has the files that need to be FTP'd using a bash script. I have everything working except the reading of the file. It works outside of the ftp script I've wrote but once I put it in the FTP script it doesn't.

Here's the Script:

#Here's where the problem is that I know of

I've been playing w/ the exclamation points to see if that could be the problem, but so far no luck.

View 6 Replies View Related

General :: Extract A String Within A String Using A Pattern?

Nov 4, 2010

i have a file name using the following pattern:

PREFIX: AR
SOURCE: LEGACY
DATETIME: YYYYMMDD_HH24MISS
SUFFIX: .txt

sample filename:AR_LEGACY_20101104_105500.txti want to extract the source which is LEGACY in this case. how do i do this using shell?

View 1 Replies View Related

General :: Awk Gsub() Command - String (column) Manipulation - Replace The Value Of The $1 Column In The Awk Print String?

Mar 7, 2010

i use this script to get the time and date of back and fourth transactions for a particular execution id. I use a substr command on the 5th column to to cut the milli seconds off the time value. - otherwise the times would look like 08:30:04.235

grep <executionID> <auditfile> | awk '{ print $1, $2, $3, $4, substr($5,1,8}
FIX -> Mon 3/1/2010 08:30:04
FIX <- Mon 3/1/2010 08:32:36
FIX <- Mon 3/1/2010 08:35:08

[code].....

anyhow - i append two sed commands to further clarify the direction of the message.

awk '{ print $1, $2, $3, $4, substr($5,1,8} | sed -e 's/->/ ->IN/g' | sed -e 's/<-/<-OUT/g'
FIX -> IN Mon 3/1/2010 08:30:04
FIX <- OUT Mon 3/1/2010 08:32:36

[code]....

I tried using an awk gsub () command within the string instead of the two seds, but it did not work:

awk '{ print gsub(/<regex>/, <replace with>,$1), $2, $3, $4, substr($5,1,8}

the sed works ok, but it would be cooler to make the replacement within the awk command:

gsub(/->/,-> IN, $1)

Is there a way where i could replace the value of the $1 column in the awk print string?

View 1 Replies View Related

General :: String Replace In Filenames - Files Already Contain The String "Soundtrack"

Jun 11, 2011

Moving right along, I have a folder of MP3 files containing various Movie sound tracks and scores. I'm using Audio Tag Tool to tag all the files at once with an "Artist" of "Soundtrack", and to inherit the "Title" tag from the file name. After that, I will rename all the files (Using Audio Tag Tool -- awesome program, btw) with the format "<Artist> - <Title>.mp3"

The problem, is many of my files already contain the string "Soundtrack", which would be redundant. I happen to be a perfectionist, so I'm unable to ignore it and move on. Hence my question to you fine folk: I want to delete all instances of "soundtrack" (-i case irrelevant) in the filenames before I go through the above steps. But, its not quite that simple. This is a sample of some of the file names:

[Code]....

View 3 Replies View Related

General :: Replacing Awk With Perl?

Jul 16, 2010

I want the output of this file to be in a column, not next to each ohter. I tired putting a a newline escape character in a few places, but it breaks the script. It is easy in awk, just ls -ltr | awk '{print $8 }'

casper@casper-laptop:~$ pwd
/home/casper
casper@casper-laptop:~$ ls -ltr > /tmp/outfile
casper@casper-laptop:~$ cat -n /tmp/moreawkreplace
1#!/usr/bin/perl

[Code].....

View 1 Replies View Related

General :: Replacing Ownership Of Certain Files?

Jan 30, 2010

Is there any working commandline alternative to # find /some/dir -group xxx -user yyy | chown xxxxx:yyyyyThe main purpose is to replace ownership and goup of certain files in subdirectories. Or nevertheless I need to write shell script for that simple operation ?

View 5 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 :: Finding And Replacing Whole Line Using Sed

Mar 19, 2011

assume that i am having the following line in a file called file1. triumph and disaster must be treated same. I want to replace this line with. follow excellence success will chase you. is it possible to do this using sed. if possible kindly post me the code.

View 6 Replies View Related

General :: Replacing A Line With Spaces?

Jan 5, 2011

I have a line like

port = 2566

I want to replace it as

port = 8080

how to do this in shell script. when i tried to do this with sed

sed -i 's/port=.*/port='$3'/' /root/$2

it is not recognizing spaces , it works only if line is port=2566 .

View 6 Replies View Related

General :: Replacing Character / Value In Certain Column

Jun 21, 2011

I need to replace a value in a file. For example the content of data.txt file is:
1 1 23
2 1 42
3 2 52
4 2 62
5 1 77
6 1 88
7 2 99
8 1 100

Could I substitute 2 in second column with 3 using awk and or sed or other command so that the data will be change as follow?
1 1 23
2 1 42
3 3 52
4 3 62
5 1 77
6 1 88
7 3 99
8 1 100

View 3 Replies View Related

General :: Replacing Part Of Filename?

Apr 25, 2010

I have just re transcoded a bunch of avi's. to tell the new ones from the old ones I put '[xvid]' at the end of all the new avi's. but now I have deleated the old avi's I want to remove the [xvid] part of the file name. This is what I have so far

Code:
#!/bin/bash
for name in *.avi
do
newname=`echo "$name" | tr -d [xvid]`

[Code]...

View 10 Replies View Related

Ubuntu :: Remove W7 From HDD Leaving Everything To 10.10

Jan 23, 2011

How can I remove w7 starter from my HDD leaving everything for Ubuntu? Se picture.. I'm using Gparted as you can see. Guessing sda 1 and 3 = w7, sda 4 = recovery and sda 2 = linux? How do i proceed? (I don't know if it matters but I installed ubuntu via w7)

View 9 Replies View Related

General :: Boot Error After Replacing Failed HD

Jan 28, 2011

I've got a 3 year old self-assembled system running Ubuntu 9.04, with an AMD Phenom 9850 quadcore with 4G ram on and M3A78-EMH-HDMI motherboard. I'm not really a hardware person, but the assembly was pretty smooth. A year ago (while running Ubuntu 8.04) I started getting messages that my HD was about to die (a 500G Western Digital). I ran out and bought two new HDs, a 1T WD Caviar black onto which I copied everything from the dying drive, and a 500G WD Caviar green onto which I installed Ubuntu 9.04. Everything went fine, except that I couldn't seem to get the system to boot if I removed the dying drive. So I just left it in. I've been getting "About to die" messages for the last year, but I had all the data on the backup 1T drive, and the system was actually running from the new 500G drive, so I didn't worry about it.

Last week the dying drive finally actually died, and the system failed to reboot on the next try, the error message was: Secondary Master Hard Disk Error No IDE Master H.D.D. Detected! Press F1 to ResumeNothing happened after hitting F1. There are 6 SATA ports, 4 red ones (1-4) and 2 black ones (5-6). Sadly, I failed to note which ports the drives were plugged into before I started tinkering. I seem to be able to replicate this error whenever the 500G drive with the master boot record is in a higher numbered port than the 1 T drive. If I reverse that so the 500G is on a lower port number, and if I make sure that the 500G drive has a higher boot priority in BIOS, then I get no error messages at all, but after the POST sequence is finished all I get is a blinking cursor at the top of the screen that doesn't respond to the keyboard (never even getting to GRUB). I can Ctrl-Alt-Delete to reboot, but nothing else has any effect.......

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

General :: Replacing Windows Xp With Ubuntu On Network?

Mar 15, 2011

I want to save some money in the office and instead of paying windows I want to use Ubuntu.

I know of way to add ubuntu to a windows server and I have recently installed a ClearOs box as a domain controller out of the box to add xp machines to. can anyone tell me how I would get an Ubuntu desktop machine to authticate for shares and login with my clearos box which is based on Centos.

If I can get this done, I can loose the windows machine and use zimbra as well instead of exchange.

View 1 Replies View Related

Programming :: Pthread - Take String From The Command Line And Creates A Thread To Print The String

May 3, 2011

I've been trying to understand pthread in C a little better. So I made a simple program that takes in a string from the command line and creates a thread to print the string. I've looked online and copied the basic concepts but there are something things I'm confused about. The programs works just fine, but I have questions. Here's what I have so far.

[Code]....

One thing I'd like to know is why the 3rd argument in the pthread_create function which is my SendMessage function needs to be typecasted to a void pointer and then send the address of the function. Also as for the 4th argument, I would see typecasting to void pointer in some of the pthread examples I saw online, but in my case I'm passing a char pointer, would this be correct? In which case would I ever want to pass a void pointer?

Do I need a pthread_exit(NULL) in my main and in the SendMessage function? If so, why? I added the sleep() function so that I could let the pthread_exit function in my SendMessage function execute first. I simply saw that the online examples on pthread had pthread_exit() in both locations.

View 6 Replies View Related

Software :: Replace A Text String In A File With A Random String - With Sed ?

Sep 2, 2010

I have a line in a text file that has 40 random characters within a tag and i want to change the characters to a new set of 40 random characters (alphanumeric a-z 0-9 etc)

The line in the text file looks like this:

Quote:

How would i go about doing that?

Also second question same as the above but how would i remove them instead of replacing them?

View 14 Replies View Related

General :: Sound Doesn't Work Anymore After Replacing RAM?

Dec 24, 2010

I replaced one old RAM module with two newer, bigger ones, but now, the sound doesn't seem to work anymore. Already ran alsaconf andOutput of lspci for the audio device:

00:07.0 Audio device: nVidia Corporation MCP67 High Definition Audio (rev a1)
Subsystem: Giga-byte Technology Device a002
Control: I/O- Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR-

[code]....

View 1 Replies View Related

General :: Removing All Traces Of GNU Java And Openjdk And Replacing With Sun JDK

Mar 20, 2011

I have installed latest Sun JDk. But when I do: java -version I still got OpenJDK version. So I completely removed OpenJDK. But now when I do:

java -version I get even older GNU java 1.5 something libgcj. So I completely removed that too but it was asking to remove bunch of dependent apps like OpenOffice.org Writer etc. Even though I need the writer, I let it go because I do not want ever to see the face of any GNU java on my linux. So everything related to GNU java is removed. Luckily I am able to start Eclipse and it works fine and start normally (apparently using the installed Sun JDK which is what I want). But now when I run

java -version I get bash: /usr/bin/java: No such file or directory Now what I need to do so that when I open any terminal window and enter java -version I should get Sun JDK version? Sun JDK is installed in /usr/java/jdk1.6.021. I also have symlinks: /usr/java/latest and /usr/java/defaults pointing to sun jdk.

As suggested in the answer, I tried the alternatives command but it did nothing. I type the --display, nothing is shown, and --config does nothing.

View 1 Replies View Related







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