General :: How To Empty Several Subdirectories

Aug 18, 2010

I looked through google but can't find an answer for this..... say I have a directory called "files"; this directory contains several other directories..... what I wanna do is delete ALL the files within the subdirectories, but NOT delete the subdirectory. Can this be done easily without having to run a command for each subdirectory?

View 8 Replies


ADVERTISEMENT

General :: Find Files In Subdirectories And Copy Them To Another Directory With The Same Subdirectories?

Nov 18, 2010

This question is very similar to this one except that I want to maintain the file's original subdirectories.

For example if I had

/temp/a/a.txt
/temp/a/a.jpg
/temp/a/b.txt
/temp/b/c.txt
/temp/d/d.txt
/temp/d/d.jpg
/temp/d/e.txt
/temp/f.txt

[Code]...

View 2 Replies View Related

General :: Create All Subdirectories Of A Path?

Dec 9, 2010

Is there an easy way to create all subdirectories of a path in linux ?

Something like

mkdir /a/b/c/d/e/f

executed in / should create directories a,b,c,d,e,f

View 2 Replies View Related

General :: Include The Subdirectories In A Chown?

Jul 19, 2010

When I installed a new copy of my distro on another partition, in order to preserve all the settings from my old my user account, I made a user account with the same name on the new installation, and then copied my old user account's files (in their entirety) to the new user account, overwriting it. I did the copying from the root account (where else? I assume the new user account can't overwrite itself while it's open), and root became the owner of everything I copied, making it impossible to open the new user account. So I then chowned the new user account's folder to myself. I still can't get in, because apparently, chown only chowned the top folder, leaving all subdirectories owned by root. How do I make chown include all subdirectories? I scanned the man page, but didn't see a parameter.

View 4 Replies View Related

General :: Delete Matching Files In All Subdirectories?

Feb 22, 2010

How can I remove all .swp files in all of my subdirectories under Linux?

View 4 Replies View Related

General :: Running A Program In Multiple Subdirectories Simultaneously

Jul 8, 2011

Performing commands in multiple subdirectories simultaneously. I'd like to run a program I've copied into every subdirectory which takes *.in files in the current directory as input files. I can find the program, but how do I tell it to run when I've found it?

View 1 Replies View Related

General :: Executing A Script In Multiple Subdirectories Simultaneously?

Sep 14, 2010

i'd like to execute in several subdirectories that all have the same name, but I don't want to have to change into each subdirectory (there are hundreds) to execute the script. All the subdirectories have the same name ("final_alignments"), but are located in parent directories with different names. All these parent directories are in the same "super parent" directory. I've tried to do this using "for/do" and "find" but no luck so far.

View 8 Replies View Related

General :: Find All First Level Subdirectories Under The Current Directory?

Jan 24, 2011

1. How can you find all first level subdirectories under the current directory?
2. How will you show the last 100 lines of the file "foo.log"?
3. How will you Stream the contents of a the log file "foo.log" as it gets written to?
4. How can you grep for a pattern on a gzip'ed file? e.g., find "foo" in bar.gz
5. Find all lines in the file "foo" which DON'T have the pattern "bar"
6. Your web server is running very slowly. If you can login to the server, what command will you run to find out cpu and memory use?
7. Extract the file foo which is a part of the tar'ed, gzip'ed file bar.tar.gz
8. You attach a usb disk to your linux desktop, but it does not show up. How can you get more information about the error?
9. What is the secure way to login to remote systems?
10. What is the difference between TELNET and SSH?
11. Given a file 'a' with the following permissions -rwxrwxrwx 1 rohit rohit 0 2011-01-24 13:30 a Change its permissions such that it is only readable and writable by its owner, not accessible by anybody else in the group and only executable by the world
12. Difference between using ' and " for quoting a string / command in a shell
13. In the attached text file (test.txt) replace all occurrences of 'red' with 'yellow' without using an editor (i.e. from the command line)
14. How would you suppress output written to stderr by a command
15. Meaning of the #! notation in scripts e.g. #!/bin/sh
16. What is the output of the attached shell script test.sh Scripting questions, all based on the attached file access.log. Use one of perl, python, ruby, or shell scripts to solve these questsions. If any answer is obtained using just the command line, please include those commands as well.
17. How many accesses were made between 10am and 11.30am on Jan 24, 2011?
18. How many unique IP addresses accessed this server?
19. For every IP address which accessed this server, output a report showing number of hits for every type of HTTP status. For e.g., IP 192.168.1.20 has 164 hits with status 404 and 1690 hits with status 200.

View 8 Replies View Related

General :: Copy All .jpg Images In Subdirectories To A Specific Directory?

Aug 5, 2010

I have .jpg files in many subdirectories from where I need to copy all the images from all the sub directories and paste them to a specific directory.I have used `cp -rf *.jpg media/sik/` which only copies the .jpg files of the directory in which I was working.

View 5 Replies View Related

General :: Trying To Display Count Of Number Of Subdirectories In Directory

Feb 7, 2011

I am a noob and I am trying to display a count of the number of subdirectories in a directory. I have been able to use find -type d to list directories and subdirs but I want a numerical value of dirs and subdirs. I know ls -l gives a count but when I try ls -l -d all it shows is "." I also have tried a combination with the -R option but nothing seems to be working for me.Please forgive my ignorance but I am working on a script for class and this is the first step.

View 3 Replies View Related

General :: Shell Scripting \ (test If A File Is Empty, If It Is Then Display "file Is Empty" Otherwise Display "file Is Not Empty")?

Oct 5, 2010

I am a final year student doign Computer systems engineering and just been introduced to linux. While still strugling to catch up with the commands, I am now given an assignment under shell scripting.I seriously am strugling to understand this question, can you please assist me.Here follows the assignment:

Operating Systems III
Some tips
e.g. (test if a file is empty, if it is then display "file is empty" otherwise display

[code]....

View 10 Replies View Related

General :: Recursively Remove Subdirectories And Files But Not The First Parent Directory?

Feb 11, 2010

I'm able to use the following to remove the target directory and recursively all of its subdirectories and contents. find '/target/directory/' -type d -name '*' -print0 | xargs -0 rm -rf

However, I do not want the target directory to be removed. How can I remove just the files in the target, the subdirectories, and their contents?

View 4 Replies View Related

General :: Giving User Write Access To Directory And Subdirectories

Aug 10, 2010

I need to give a user write access to /var/www and its subdirectories. The current directory permissions are as follows:rwx r-x r-x root root

I added the user to the root group but that didn't seem to help.I read I could chmod -R to change the access to write for the www directory and subdirectories but I don't want to change things and mess up the website. How can I give the user access to write to the www directory and subdirectories without messing anything up? Would changing the www directory group owner to his group cause an issue anywhere?

View 3 Replies View Related

General :: Get A Shell Script To Loop Through A Number Of Directories And Subdirectories?

Jul 27, 2010

I'm looking to get a shell script to loop through a number of directories and subdirectories,looking for files that contain a particular substring, and renaming the file by replacing the search string with a different substring. For example if you had a directory full of folders that contained digital photos (along with various other files which would need to remain unaffected), and the intent was to remove the "DSC_" prefix from several thousand files buried within. I've whipped up a rather long-winded solution that works well for this purpose but chokes on directory names with spaces. I am reasonably sure there's a 2 or 3-liner that would accomplish this exact same task.

function investigate
{
path=$1
for file in `ls $1`
#for file in *

[code]....

View 1 Replies View Related

General :: Command To Find A Specific Word In Directories And Subdirectories?

Jun 7, 2010

tell me the command used to find a specific word in directories and sub-directories in linux?

View 4 Replies View Related

General :: Script To Open All Subdirectories Of A Single Directory And Then Run A Command?

Mar 24, 2010

I am trying to write a very simple script that will go to every subdirectory of a single directory and run a command (lets call it make_ndx).I know I can write this the long way with in a text document with something like:

cd /"the directory"/"the 1st subdirectory"
make_ndx
cd ..
cd "the 2nd subdirectory"
cd ..

Alternatively, I also tried: for i in 'find /path/somemorepath -type d -mindepth 1'; do cd $i; make_ndx -f *.gro; done which returns me with the error cd: find: no such file or directory. But if I run the find command by itself to test if I am calling the right directories, it gives me the exactly the output I am looking for. Any ideas? Should I just write the find results to a file and loop through the contents of the file (which seems a little bit like overkill) or am I just making a simple typographical mistake and I am just not seeing it?

View 7 Replies View Related

General :: Allow Normal Users To Mount Tmpfs Under Subdirectories Of Their Home Directory?

Oct 11, 2010

How can I allow normal users to mount a tmpfs under any subdirectory owned by them?

View 3 Replies View Related

General :: Command Line - Automating A Task - Copy All Subdirectories And Files From One Directory To Another

Jun 10, 2010

I need to copy all subdirectories and files from one directory to another ever 5 minutes or so, with the old data automatically being overwritten with the new data. I'd also like this to run at startup. Is there any way this can be done? If so, what program would I need to schedule the automation and what is the command line I would need.

View 2 Replies View Related

General :: List/find All Regular Files In All Subdirectories Excluding Binary Files

Oct 5, 2010

I know I can do find . -type f, but that includes binary file and I couldn't find a way to exclude them with find

View 4 Replies View Related

General :: Rename Multiple Files In Multiple Directories/subdirectories Recursively?

Aug 23, 2010

I am to rename all the files within a directory (which contains multiple subdirectories) recursively without invalid characters.

I tried the coding posted above.

find . -type f -printf '%p
' | while read file; do
oldfile=$(basename "$file")
newfile=$(echo "$oldfile" | sed 's/[^A-Za-z0-9_.]/_/g')
if [ ! "$newfile" == "$oldfile" ]; then
echo mv "$file" "${file%$oldfile}$newfile"
code....

but I get an error on both of them stating "find: bad option -printf find: [-H | -L] path-list predicate-list"

View 9 Replies View Related

General :: Search In "/" And All Subdirectories - All Files Greater Than 30 MB

Feb 21, 2010

I need to search in "/" and all subdirectories, all files greather than 30 MB.

View 5 Replies View Related

General :: How To Empty A File

Jul 15, 2010

I have a large file that a process writes to. I would like to empty that file. If I delete it the process will stop writing to it. Just flush the content but keep the file.

View 9 Replies View Related

General :: Using An Empty Ex4 Partition

Apr 12, 2011

I have Ubuntu in one partition . The partition is about to be full..I have a spare partition which I thought could merge with the existing..But I guess it is not possible. I am slightly confused with the way linux stores the files. There is a root directory and within that there are boot ,Var,tmp and home..

Suppose I install an application from a package manager , I really do not understand where the path is ...Supose I want to store certain new applications in the spare partition , how do I tell the system? Also while installing it doesnt give a choice regarding the path ...All I see is a couple of files exracted and when it completes , it sits on the menu neatly. From a storage perspective how do you gain control? Say in Win , normally any package will ask for the path which you can customize..How do you plan the storage of files in Linux?

View 7 Replies View Related

General :: List Only Non-empty Files Using Ls?

Sep 23, 2010

How can I list (using ls) all files that are not empty (size > 0) using linux?

View 7 Replies View Related

General :: Command To Empty Recycle Bin?

Oct 15, 2010

Simple question but even google does not come up with an answer, seems to be too easy that someone else asked it ;). Could anyone tell me what is the shell command to empty the garbage bin under Linux?

View 3 Replies View Related

General :: Empty Map In Nautilus But Not In Terminal?

Aug 25, 2010

Lucid 10.04 distro. On an ext usb hd I have 250วด info in 6 directories. All directories are visible in terminal mode mod 755. All directories are visible in nautilus, all files are visible except in one directories which contains 200gig of videos.A file search shows all in all directories. All files can be opened mv, cp etc. I can move a file from this directory to another and all is well.In my Debian 5.05 distro with the same hd and directories etc, this problem does not occur.

View 6 Replies View Related

General :: How To Delete All Empty Folders

Jun 7, 2010

I just had a bad experience with a server, and now i have a 17GB lost+found. It appears a lot of the stuff in there are folders which are empty. Since those really serve no purpose as far as recovering data from what I can tell, is there a slick way to delete just the empty folders from my /data/lost+found folder, leaving me with just the stuff I truly need to look through?

View 3 Replies View Related

General :: Everything Is Going Great \ Mail.log Is Empty?

Apr 15, 2010

OS: DebianMail Server : PostFixAV: ClamAVI have a newly created SMTP mail server and so far, everything is going great. Over 300 mails are being sent a day and no major issue has come up since then.However, the thing is that every morning I'm rotating my logs so that mail.log becomes mail.log.0 and so on.Its working fine but this morning, mail.log after having been empty and rotated, is empty and nothing is being logged anymore in it.The strange thing is that mail.info is but not mail.log. Mail server is still working well, syslog shows nothing strange, mail.err either, everything is working smoothly as its always been since I started everything, but my mail.log is being kept empty

View 2 Replies View Related

General :: Forcing Tar To Create An Empty Archive?

Apr 21, 2010

I'm trying to use tar to tar files before transfer, so I can keep the entire file path rather than losing it along the way. However, when I try to tar an empty folder, it tells me that it is cowardly refusing to create an empty archive. I want to keep the empty folder on the other end, but don't want to put anything else into the archive to make it non-empty. Is there any way to do this?

View 1 Replies View Related

General :: Empty Bash Command Line?

Sep 28, 2010

I am looking for a way to delete the currently entered commandline without wasting seconds on the "Backspace"-key.

For example I scrolled the bash history and have a long commandline that would execute when I pressed ENTER:

~$ aptitude search openssl | grep dev

But now I decide that I do not want to execute this command. Can I get an empty prompt fast without deleting the whole line with Backspace? On the Windows "cmd" you can just press ESCAPE and it is gone. This behavior would be what I want.

The question may seem trivial but this is bothering me for a long time now.

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved