So, I have a requirement to delete all files from specific folders within a directory. These are folders that end with "-outputs" in their names and I need to delete all files in those particular folders.
Is there a command in linux that lets you do that?
You can execute the following command:
rm $YOUR_PATH\*-outputs
Change $YOUR_PATH to the path where the files are located.
If you want to ignore nonexistent files and arguments, and avoid the prompt, you can use the -f option.
rm -f $YOUR_PATH\*-outputs
You can see the different rm options here:
rm Linual manual page
Related
I want to ask when I delete file in folder symlink target, is it possible make the file is still available in original file?
I use ls -n /folder /target but when I delete file in /target , in original folder deleted too.
Remove Symbolic Links with rm
rm symlink_name
Remove Symbolic Links with unlink
unlink symlink_name
Unlink command and rm command without -R option doesn't delete regular directory. The two commands delete symbolic link from directory because it's considered as a file so, when using the rm or unlink command to remove a symbolic link from a directory, make sure you don’t end the target with a / character because that will create an error
Please read more in documentation, man pages etc.
As I understood question - you should remove symlink to directory, but make symlink for each file in directory to target directory. So you will have two normal directories and lot of symlink for files.
Only this way you can delete one particular file in target directory and still have it in original directory
If you want to make it work both ways - to delete file in original directory and still have it in target - make non symlink but hard link with ln for each file.
I'm trying to make a copy of one directory files into another directory.
I have Desktop/projectOne and Desktop/projectTwo and I'm trying to copy projectOne files into projectTwo. I need to use terminal for this as I need to copy hidden files also and I'm not familiar with linux commands...
So my question is...
What commands do I have to use to copy all files (hidden files included) from Desktop/projectOne to Desktop/projectTwo?
What commands do I have to use to copy only hidden files from Desktop/projectOne to Desktop/projectTwo?
Thanks in advance.
cp -r
Example: cp -r /oldfolder /home/newfolder
Noticed: if newfolder is already exist it will create new folder in it
/home/newfolder/oldfolder
Let say the command be my_command
And this command has to be prepared specific files (file1, file2, and file3) in the current working directory.
Because I often use my_command in many different directories, I'd like to keep the certain files in a certain directory and execute my_command without those three files in the working directory.
I mean I don't want to copy those three files to every working directory.
For example:
Directory containing the three files /home/chest
Working directory: /home/wd
If I execute command my_command, it automatically recognizes the three files in /home/chest/
I've thought the way is similar to add $PATH and not the executable files but just files.
It seems like the files needs to be in the current working directory for the vasp_std command to work as expected, I am thinking that you could simply add all files in a include folder in you home directory and then create a symbolic link to this folder from your script. In the end of your script the symbolic link will then be deleted:
#!/bin/bash
# create a symbolic link to our resource folder
ln -s ~/include src
# execute other commands here
# finally remove the symbolic link from the current directory
unlink src
If the vasp_std command require that the files are placed directly under the current working directory you could instead create a symbolic link for each file:
#!/bin/bash
# create link for to all resource files
for file in ~/include/*
do
ln -s $file `basename $file`
done
# execute other commands here
# remove any previously created links
for file in ~/include/*
do
unlink `basename $file`
done
I am a beginner of Linux system. Now I have a butch of files and folders want to be deleted. How can delete them one time using some command line?
Firstly I think you need rm command, then since you want to recursively delete the files or folders, you have to choose the option -r, -r means recursively delete something. Below is the link for details using rm command in Linux system.
https://www.computerhope.com/unix/urm.htm
In Linux, how can I delete all files in particular directory? For example /home/xd/karthik is my path; I want to delete all files in the above directory, if the disk usage exceeds 90%. How can I write a script for that?
rm /path/to/directory/*
add rm -r to remove the file hierarchy rooted in each file argument.
dont need script just basic shell command