Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
sed -i "$line c between '$(date --date="- 1 month" +%Y-%m)-01' and '$(date --date="+ 3 months" +%Y-%m)-01'" $filename
where $line is the line number.
c is the sed command to replace the line with the following text.
date has handy time difference calculation and output format options.
If the line number might change, you will want to use regular expressions to find the right line.
Please ask where you need more explainations.
It works, but it entirely replace the other content in the line ,
This is the content of the file: this all content comes in a single line
select b.id as cli_id,b.login as cli_login, b.pname as cli_name, b.cname as cli_company, b.phone as cli_phone, b.email as cli_email, (select (value / 1048576) from Limits where limit_name='disk_space' and id=b.limits_id) as Client_Package, b.cr_date, (select FROM_UNIXTIME(value,"%Y-%m-%d") from Limits where limit_name='expiration' and id=b.limits_id) as Client_expire, If(b.status=0,'Active','Inactive') as Cli_Status, a.name as dom_name, If(a.status=0,'Active','Inactive') as Dom_Package, a.cr_date as dom_create, (select FROM_UNIXTIME(value,"%Y-%m-%d") from Limits where limit_name='expiration' and id=a.limits_id) as dom_expire, (select (value / 1048576) from Limits where limit_name='disk_space' and id=a.limits_id) as Dom_Package, round((a.real_size / 1048576)) as Dom_usage from domains a, clients b where (select FROM_UNIXTIME(value,"%Y-%m-%d") from Limits where limit_name='expiration' and id=a.limits_id and (FROM_UNIXTIME(value,"%Y-%m-%d") between '2011-08-01' and '2011-12-01') ) and a.cl_id=b.id group by a.id;
between '2011-08-01' and '2011-12-01'
in that i need to replace the date part alone.
if i used your command means it entirely replace the other content in a line and display "between '2011-08-01' and '2011-12-01'" only this content
i think in sed there is option to change the particuar word in a line, i will check thanks for your help dude you made my day.
i dont feel ashame never ever!! i know my values and goals, as a senior member i didnt expect from you, words are most harmful than bullets..hmmm days are not to far to become master in linux domain,
Again, I really hope you do advance...but until you start applying what you've been told, learning on your own, and stop asking to be spoon-fed answers, you won't. Instead of posting over and over "I get this error when I ran the command..what do I do??", try experimenting with it, on your own. Figure out your own answers.
After over a year here, you're not a 'newbie' anymore...you should be able to figure out how to write a simple script, use sed and awk, and make things work