LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
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 11-13-2008, 07:03 PM   #16
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,358

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751

To create an empty file, use the 'touch' cmd

touch .new_account

http://www.kholix.com/wiki/index.php...shell_commands
The rute link above is good, also http://www.tldp.org/LDP/abs/html/
 
Old 11-14-2008, 11:19 AM   #17
dmgctrl
LQ Newbie
 
Registered: Nov 2008
Posts: 8

Original Poster
Rep: Reputation: 0
Thanks for your reply! I used touch to create a file, but I am trying to create LOTS of the same empty files in lots of directories, so I tried:

touch /home/*/public_html/ .new-account

but it didnt spit out an error message, or create the files. Any ideas?
 
Old 11-14-2008, 11:46 AM   #18
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
It looks like you have put a space between the path and the file name, so you have simply touched (changed the timestamp) of all the public_html directories in every user's home and created a file .new_account in the current directory. Anyway, if you do:
Code:
# touch /home/*/public_html/.new-account
touch: cannot touch `/home/*/public_html/.new-account': No such file or directory
you get an error because the shell is confused if she tries to expand to non existent file names. So again keep it simple and use a loop:
Code:
for dir in /home/*/public_html
do
  touch $dir/.new_account
done
 
Old 11-14-2008, 12:36 PM   #19
dmgctrl
LQ Newbie
 
Registered: Nov 2008
Posts: 8

Original Poster
Rep: Reputation: 0
Thanks AGAIN! That worked. (More cold beer en route!) Oddly though, when I run the earlier command you supplied:

while read name
do
dir=$(dirname "$name")
echo mv "$name" "$dir/.new-user"
done < <(ls /home/*/.new-account)

It doesn't show the newly created files, which seems pretty weird. The only difference I see it that the ones that were created by:

for dir in /home/*/public_html
do
touch $dir/.new_account
done

are owned by root:root , whereas the previous ones were owned but the user:user. Why will

while read name
do
dir=$(dirname "$name")
echo mv "$name" "$dir/.new-user"
done < <(ls /home/*/.new-account)

not detect the root owned .new-account files?
 
  


Reply



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
Renaming files Viablade Linux - Newbie 11 10-10-2008 01:54 PM
help renaming files please balistic Linux - Newbie 2 07-29-2007 03:35 PM
renaming files starwarsfan982 Linux - Software 7 10-30-2006 02:06 PM
renaming files TomalakBORG Linux - Newbie 4 12-24-2005 10:14 AM
Renaming files in one go saurya_s Linux - Software 1 01-12-2004 01:16 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:55 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
Open Source Consulting | Domain Registration