vovapm.blogg.se

Console command find file linux
Console command find file linux









console command find file linux

A slightly safer option is to use the -i option, which will prompt before deleting each file. There is no way of restoring a deleted file (except from a backup copy) so be careful when deleting files. To delete the file type rm followed by the file name (can include a path). Touch -m -r referencefile thisfile Removing a file (rm)įiles are removed by using the rm command. This is sometimes used for backup scripts, where a modification time can be set to the same as another file so that it can be identified if the file needs to be included in an incremental backup. The following example will set the modified date to be the same as another file. This is based on the POSIX version of the touch command (there is another version that does not adhere to the POSIX standard, but the POSIX version is the most common). Will set the last modified date of thisfile to 25th may 2012, 17:00. If the time is not specified using -t or -r, then the current time will be used. The new time is given using the -t option, to specify the time, or the -r option to set the value to be the same as another file. The -a option will change the access time, the -m option can be used to change the last modified time.

console command find file linux

In fact the touch command real function is to change the modification and/or access timestamps of a file. Whilst this is often the most common use of the touch command it has other uses as well. are hidden (cannot be seen from an ls without the -a option) Should not be the same as a system commandįilenames starting with. Should not include shell metacharacters (characters used by shell pipes etc) *?/& :!$\'" Uppercase, lowercase, numbers, spaces can be included in a filename it is advised against this The name should be descriptive of the contents The following rules should be followed when creating a file: The format is to have the filename after the touch command. It is also possible to create a blank file using the touch command. Mkdir -p /home/stewart/newdir1/newdir2 Making a New File / Changing the File Timestamps (touch)Ī common way of making a file is to save to a file from an application. If the previous directories don't already exist then using the -p option will also create the parent directories if they don't exist.

#Console command find file linux full

The file directory could also have been created using a full path however all the previous directories must already exist. Directories can be created either singularly (in which case all directories above it must already exist) or several at a time allowing parent directories to be created at the same time.Ĭreating a single directory from the current directory is done by mkdir followed by the name of the new directory. New directories can be created using the mkdir command. The -l option is used to give more information, including: permissions owner, and owning group file size and date last modified in addition to the filename. Typing ls on it's own will list all the files and directories contained within the current directory. The ls command can be used to list the contents of a directory.

console command find file linux

The $OLDPWD variable is useful if you want to move back to the directory you were at previously.Ĭd $OLDPWD Listing the Contents of a Directory (ls) To view the current working directory you can view the $PWD variable, and to view the previous directory there is the variable $OLDPWD. There are also two shell variables that are normally set. The pwd (print working directory) command will return the name of your current directory.

console command find file linux

When moving around the directory structure it's easy to forget where you are. To change directory use cd followed by either the absolute or relative directory. You can move around the directories by using the cd (change directory command). This is normally /home/username (for username stewart that will be /home/stewart). When first logging onto a UNIX system you will normally be in your "home" directory. These are command-line programs that can often be used together by using pipelines or redirects (see the Command Basics Reference Guide). The guide lists some of the useful commands.











Console command find file linux