Linux, FreeBSD, Juniper, Cisco / Network security articles and troubleshooting guides

FAQ
It is currently Sun Aug 20, 2017 4:47 am


Guides and tutorials for Red Hat Linux, Debian, Suse and others.

Author Message
LaR3
  Post  Post subject: Linux Shell: "Cannot overwrite existing file" when the file is owned by you  |  Posted: Mon Aug 24, 2009 10:26 am

Joined: Mon Aug 03, 2009 4:55 pm
Posts: 19

Offline
 

Linux Shell: "Cannot overwrite existing file" when the file is owned by you

If the shell noclobber environment variable is set, you will not be able to overwrite a file's content by redirecting some output to it.
Code:
# echo "2nd Overwritten content">tmp.file
bash: tmp.file: cannot overwrite existing file

First option would be to disable the noclobber variable:
Code:
# set +o noclobber; set -o | grep nocl
noclobber       off


The second option is to use the pipe (|)right after the redirection sign:
Code:
# echo "2nd Overwritten content" >| tmp.file
# cat tmp.file
2nd Overwritten content

_________________
Humble user
http://www.ivorde.ro





Top
Display posts from previous:  Sort by  
E-mail friendPrint view

Topics related to - "Linux Shell: "Cannot overwrite existing file" when the file is owned by you"
 Topics   Author   Replies   Views   Last post 
There are no new unread posts for this topic. Linux Shell: Protecting against accidental output redirection and file overwrite

LaR3

0

1124

Mon Aug 24, 2009 10:14 am

LaR3 View the latest post

There are no new unread posts for this topic. Linux reloading inittab without reboot

debuser

0

3014

Thu Nov 26, 2009 4:49 am

debuser View the latest post

There are no new unread posts for this topic. How to change crontab editor in Debian Linux

mandrei99

1

3635

Tue Mar 08, 2016 6:53 pm

tsuchan View the latest post

There are no new unread posts for this topic. Linux umount -f: umount2: Device or resource busy

debuser

0

1532

Fri Apr 09, 2010 7:52 am

debuser View the latest post

There are no new unread posts for this topic. Linux change the password with output from echo command (standard input)

debuser

0

1864

Thu Jan 14, 2010 5:58 pm

debuser View the latest post

 

Who is online
Users browsing this forum: No registered users and 0 guests
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum
Jump to:  
cronNews News Site map Site map SitemapIndex SitemapIndex RSS Feed RSS Feed Channel list Channel list


Delete all board cookies | The team | All times are UTC - 5 hours [ DST ]



phpBB SEO