Sed Command To Global Change If It Match Some Pattern

This is what I have
FINPXXX
FOLLOWS FINPJOB99
CALENDAR1 FINP456
CALENDAR2 FINP374
CALENDAR3 FINPOE9

End result I want is
FINPXXX
FOLLOWS FINPJOB99
CALENDAR1 FIND456
CALENDAR2 FIND374
CALENDAR3 FINDOE9

I have 3 commands
sed 's/CALENDAR1 FINP/CALENDAR1 FIND/g'
sed 's/CALENDAR2 FINP/CALENDAR2 FIND/g'
sed 's/CALENDAR3 FINP/CALENDAR3 FIND/g'

I cannot just do sed 's/FINP/FIND/g' because there are a lot of 'FINP' pattern in the file I need to keep.

The problem I have is I have a lot of files, and I have to go thru each file to find out how many CALENDAR# pattern I have. Is there a better way to do the sed command? I tried this
sed 's/CALENDAR. FINP/CALENDAR. FIND' But it replaces all CALENDAR# to CALENDAR.

Thank you.


Similar Content



How Can Active Outlook Calendar Be Integrated To Linux Ubuntu Thunderbird Mail Program

Dear all,

I recently installed, for the first time, Linux to my Lenovo X220 .
First impression is good, everything is running smooth so far :-)
I do though have ran into a wall when trying to integrate my company Outlook calendar into Thunderbird Mail.
Ubuntu 14.04 and Thunderbird 1:31.6.0 is what I have.
In our company we do use shared Outlook calendar to track and update many events on daily bases and I'm the only Linux user and would hate to give up making this work on my end. Now updating my entries via mobile phone and Ipad..
Any simple solution to this to work on my Laptop? ;-)

Is It Food Have Find Command Running In Cron Every Day Once To Delete Older Files

I need to clean-up some folder. I have a cron job which uses find command to find and delete 25 days older file.

Code:
find $FOLDER_PATH/$FOLDER -depth -regex  ^$FOLDER_PATH/$FOLDER/[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ -type d -mtime +25  -exec ls -ld {} \;   >> /tmp/deleted_folders.log

When this running it occupies 1-3% of cpu. And it may take longer time based on the folder size.

Is it ok to have find command running as cron job ?

Ubuntu Directories

Hi there. I have Ubuntu 14.04 installed. Actually I have been doing a lot of work in this OS for about a year. The thing I cannot still comprehend is how to find files I installed. In this particular case I need glut.h for g++ compiler. So I go here, do this command;

Code:
sudo apt-get install freeglut3-dev

And find out that I already have the newest version (which I have suspected since I recall installing it).

So, the next step is to find the glut.h file and reference it with #include command. I cannot find it anywhere. This website says it has to be he

Code:
/usr/lib/x86_64-linux-gnu/libglut*

Why's the asterisk? Is it a footnote or part of the code?

I don't seem to have /usr/ directory. I cannot find it anywhere.

How does Ubuntu directory work?

Thanks, - A.

Find Command Fear And Loathing

Its plentiful documentation fails to explain how to use it. After googling all over the world and hunting down examples, it turns out they don't work as the man page indicates if you alter them in the slightest. In fact I know what I want to find, where it is, how to describe it; but the problem is getting find to list that file or those files and moreover making sense of its horrid documentation. It lists too many things. It ignores -prune. It either does nothing or too much. Its a horrible, horrible program, and you are expected to make up the difference by experimentation.

Its so complicated as to make it more worthwhile just to list every file and filter them out with other utilities. Honestly, why go through so much trouble to learn about a command that is as obfuscated as a heartpump?

Sure its great for listing all the files and directories in one subdir, but if you want to exclude multiple dirs or files forget it. Pipe it through grep.

How To Delete Number Of Files

I'm trying to figure out if find could do this. I have a folder with 1000 files. I want to delete 150 files on that folder regardless of timestamp and filename. Is there a tool, command or option on find that could do this, please let me know.

Combining mtime or ctime to find is not advisable since it will not count the files or even if there are matches, I would still need to sum up the files until I reach 150 files.

Any suggestions?

Getting And Installing Python 3.5 Help

One week user of Ubuntu v15 and I have tried to install the file Python-3.5.0a1.tar gz but without success. The following points have arisen.
1). The file was downloaded. OK
2). The file was extracted to the Desktop as Python-3.5.0a1
3). Using sudu apt-get install Python-3.5.0a1, the message 'file not found'. Why not!
4). Looking into the extracted files it seems that this is a source package and therefore cannot be installed as is?
5). Finally, using the bash command 'find' it could not find the above file either.
Can someone kindly sort this out for me.
Thanks.

Question Using Cp And Find Commands.

I am needing to know the command(s) to find and copy all files modified, within the last 90 days, of one users home directory to my home directory.

Find 30 Days Old And Delete Prints Error Msg File Not Found After Deleting It

I have a shell script to find folders which are 25 days older and delete it, and put the deleted folder details into log file like this

Code:
 find /ahome/xxx/$FOLDER -type d -mtime +25  -exec ls -ld {} \;  -exec rm -rf {} \;  >> mylogfile.log

after running this command it deletes the folder and logs the folder deleted. But also print error msg
Code:
find: /ahome/prksh/dir/test: No such file or directory

How to suppress the error msg

Exporting Log Data To A File That Matches Stdout

hey guys,

Let's say I want to find out which log files have related ntp information in them. I use cat and grep to search through the files in /var/log and then export that to a file. this is the command...

# cat /var/log/* | grep ntp > /home/log.txt

The file created from this command will not include the directories the log entries are apart of. Why not? For example, if you do this same command without exporting to the /home/log.txt file it will show you in stdout which directory each log entry is in. Hope I'm making sense here. My question is, is there a clever way to export to a file in a way so that the file created is structured exactly like the stdout of the command below?

# cat /var/log/* | grep ntp

Debugging In Ns2

I am trying to develop a new routing protocol in ns2. Although i have given a command in tcl file that should be called from command function present in .cc file. But it is not doing so.
Could we debug this and find the point where is the problem. If yes then how ?

I have heard that there are debuggers in ns2 . But this is for tcl or c++ ....
Could any one please help me ... How can i proceed further.

Thanks for ur help