LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This 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!

Notices


Reply
  Search this Thread
Old 01-16-2014, 03:14 AM   #1
sachin.davra
Member
 
Registered: Jul 2013
Posts: 213

Rep: Reputation: Disabled
create file with touch and echo output to that file


i am writing a .repo file using echo command after creating that file with touch command. but i am not able to do what i want.
Code:
echo "[local repo]" "\n" "name=local repository for updating packages" > /etc/yum.repos.d/local.repo
above command should write in the file like
Code:
[local_mirror]
name=local repository for updating packages

how can i achieve this task?

Last edited by sachin.davra; 01-16-2014 at 03:16 AM.
 
Old 01-16-2014, 03:17 AM   #2
qrange
Member
 
Registered: Jul 2006
Location: Belgrade, Yugoslavia
Distribution: Debian stable, amd64
Posts: 805

Rep: Reputation: 32
check permissions, usually only root can write to /etc
 
Old 01-16-2014, 03:18 AM   #3
sachin.davra
Member
 
Registered: Jul 2013
Posts: 213

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by qrange View Post
check permissions, usually only root can write to /etc
i am trying with root only but i think command is wrong. i am not sure about command.
 
Old 01-16-2014, 03:19 AM   #4
zhjim
Senior Member
 
Registered: Oct 2004
Distribution: Debian Squeeze x86_64
Posts: 1,748
Blog Entries: 11

Rep: Reputation: 233Reputation: 233Reputation: 233
You need to enable backslash interporetaion of echo. Use the -e option.

Just so we can help you better in future it would have been great if you would have shown what you output was. Just be as verbose as possible and as quiet as feasible.
 
Old 01-16-2014, 03:20 AM   #5
SAbhi
Member
 
Registered: Aug 2009
Location: Bangaluru, India
Distribution: CentOS 6.5, SuSE SLED/ SLES 10.2 SP2 /11.2, Fedora 11/16
Posts: 664

Rep: Reputation: 80
Quote:
echo "[local repo]" "\n" "name=local repository for updating packages" > /etc/yum.repos.d/local.repo
well this doesn't seems to be nice use of echo!!! please read man echo.

try this:
Code:
echo -e "[local repo]\nname=local repository for updating packages\nbaseurl=http://some/site/some/page\ngpgcheck=0" > /etc/yum.repos.d/local.repo
 
1 members found this post helpful.
Old 01-16-2014, 03:28 AM   #6
sachin.davra
Member
 
Registered: Jul 2013
Posts: 213

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by SAbhi View Post
well this doesn't seems to be nice use of echo!!! please read man echo.

try this:
Code:
echo -e "[local repo]\nname=local repository for updating packages\nbaseurl=http://some/site/some/page\ngpgcheck=0" > /etc/yum.repos.d/local.repo
Thanks for quick response. i was not aware about -e. i used it like u mentioned above and it's done. Anyway i know this is not nice use of echo but i wanna write it in %post section of kickstart file.

Thanks to everyone for their valuable time.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Can't create file using echo: /proc/sys/net/ipv4/ip_local_port_change rsumbeling Linux - General 4 07-17-2013 05:20 AM
Can dd be used to create an output file larger than the input file? R00ts Linux - Software 4 08-06-2012 11:28 AM
smarty Warning: touch(): Unable to create file... dussel Linux - Software 2 12-29-2006 07:17 PM
Create file using 'touch ./tmp.$$', file tmp.3941 is created, why? huangyanfeng Linux - General 1 04-13-2004 04:36 AM
Using echo to output a string to a file with forward slashs chrisk5527 Linux - General 15 06-21-2003 03:04 PM


All times are GMT -5. The time now is 12:58 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration