technical solution-Unix/Linux tutorial || File Handling commands by Shiva unix command tricks from Techmirrors

technical solution-Unix/Linux tutorial || File Handling commands by Shiva unix command tricks from Techmirrors



DURGASOFT is INDIA’s No.1 Software Training Center offers online training on various technologies like JAVA, .NET , ANDROID,HADOOP,TESTING TOOLS …

SourceTechmirrors

A batch file is a text file that stores commands that are executed by the Command Interpreter. It is generally used to simplify the execution of many commands for a given task. When the batch file is run (by double clicking on this file within Windows Explorer), a shell program (command.com or cmd.exe) reads the file and executes the commands one line at a time. Batch files generally have the extension of.BAT (all versions of Windows) or.CMD (Windows NT).

When would you use a batch file? Whenever you have a need to open several programs for a given task. For example, when it comes time to pay the monthly bills you generally would open a browser to access online banking, open a spreadsheet to track payments, and the Calc program for calculations. A single batch file can easily open all three with a single click. Within it, you would create the following commands:

NOTE: The following examples and file paths are from Windows 7. XP paths may be different for some programs as well as for MS Office (Office 2007 is used in the example below) on your Computer.
Also, due to some sites not allowing the use of back slashes, the examples below use forward slash for folder paths. When creating your batch files, use a back slash in the folder path.

  • start /d C:/Windows/System32 calc.exe
  • start /d “C:/Program Files/Mozilla Firefox” firefox.exe
  • start /d C:/finance/spreadsheets budget.xls

When creating a batch file, use the Notepad program (or any other text editor) and save it with a.BAT extension (not the default.TXT extension).

Let’s quickly review each command listed above. First, the Start command instructs Windows to open a separate window within which the program executes.

Second, the /d is called a Switch and instructs the Windows to read the following information as a file or command path for locating the program. If there are spaces in the path, the complete path will need to be placed in double quotes.

Third, the name of the file to be executed is added, including its extension.

And fourth, if there is a file or URL to be opened, then this is where it is placed. For example, the budget spreadsheet budget.xls.

The above is a simple example. Batch files can handle more complex tasks. Below is an example of a complex batch file…

  • @echo off
  • color 3
  • title Conditional Shutdown
  • set /p name=enter a name:
  • :start
  • cls
  • echo Hi, %name%
  • echo.
  • echo 1.Shutdown
  • echo 2.Quit
  • set /p choice=enter your choice 1,2:
  • if %choice%==1 goto shutdown
  • if %choice%==2 exit
  • :shutdown
  • cls
  • set /p sec=enter the number of seconds that you wish the computer to shutdown in:
  • set /p msg=enter the shutdown message you wish to display:
  • shutdown -s -f -t %sec% -c “%msg%”
  • echo shutdown initiated at %time%
  • set /p cancel=type cancel to stop shutdown
  • if %cancel%==cancel shutdown -a
  • if %cancel%==cancel goto start

What are file handling commands in Linux?

Linux Commands – Working with files and directories

  1. pwd.
  2. ls.
  3. mkdir.
  4. rmdir.
  5. cd.
  6. touch filename.
  7. rm filename.
  8. cp file1 file2.

What is the use of cat and cp command?

cp makes a significant difference: By definition, cat will expand sparse files, filling in the gaps with “real” zero bytes, while cp at least can be told to preserve the holes. Sparse files are files where sequences of zero bytes have been replaced by metadata to preserve space.

What are basic commands?

BASIC Commands

  • Statements. There were fifteen statement types in the original BASIC. …
  • Arithmetic Expressions. Besides the four standard arithmetic operations, BASIC includes raising-to-the-power, the symbol of which is “^”. …
  • Variables. …
  • Arrays. …
  • PRINT Statements. …
  • Defined Functions. …
  • Example Programs. …
  • Commands.

What is file management command?

File Management Commands – Ctd

• rmdir directory name – remove directory (it must be empty to be removed. • pwd – gives you the name of the current (working) directory. • cp file1 file2 – copy the first file to the second file. • mv file1 file2 – rename (i.e. move) the first file to the second file name.

Is command used for?

The IS command discards leading and trailing blank spaces in the terminal input and converts embedded blank spaces to single blank spaces. If the text includes embedded spaces, it is composed of multiple parameters. Two commands related to the IS command are IP and IT.

What are Linux commands?

Linux is a Unix-Like operating system. All the Linux/Unix commands are run in the terminal provided by the Linux system. This terminal is just like the command prompt of Windows OS. Linux/Unix commands are case-sensitive.

How do you end a cat command?

txt and test2.txt, which you can use as sample files to test out the other commands.

  1. Open a terminal window and create the first file: cat >test1.txt.
  2. The cursor moves to a new line where you can add the wanted text. …
  3. To exit the prompt and write the changes to the file, hold the Ctrl key and press d.

How do you copy a file to a cat?

Copy a text file

Normally you would copy a file with the cp command. You can use cat to make copies of text files in much the same way. cat sends its output to stdout (standard output), which is usually the terminal screen. However, you can redirect this output to a file using the shell redirection symbol “>”.

How do you use mv?

mv command is used to move files and directories.

mv command options.

optiondescription
mv -fforce move by overwriting destination file without prompt
mv -iinteractive prompt before overwrite
mv -uupdate – move when source is newer than destination
mv -vverbose – print source and destination files

What is the output of who command?

Explanation: who command output the details of the users who are currently logged in to the system. The output includes username, terminal name (on which they are logged in), date and time of their login etc. 11.

How do I learn basic Linux commands?

Linux Commands

  1. pwd — When you first open the terminal, you are in the home directory of your user. …
  2. ls — Use the “ls” command to know what files are in the directory you are in. …
  3. cd — Use the “cd” command to go to a directory. …
  4. mkdir & rmdir — Use the mkdir command when you need to create a folder or a directory.

What are programming commands?

In computing, a command is a directive to a computer program to perform a specific task. It may be issued via a command-line interface, such as a shell, or as input to a network service as part of a network protocol, or as an event in a graphical user interface triggered by the user selecting an option in a menu.

What are the three types of files in Linux file management?

In Linux there are basically three types of files: Ordinary/Regular files. Special files. Directories.

Ordinary/Regular Files

  • Readable files.
  • Binary files.
  • Image files.
  • Compressed files and so on.

How do I manage files in Linux?

In the Linux operating system, each entity is regarded as a file.

Let’s now delve into the basic file management commands that will help you create and manage your files on your system.

  1. pwd Command. …
  2. cd Command. …
  3. ls Command. …
  4. touch Command. …
  5. cat Command. …
  6. mv Command. …
  7. cp Command. …
  8. mkdir Command.

What is grep command in shell script?

Grep is an acronym that stands for Global Regular Expression Print. Grep is a Linux / Unix command-line tool used to search for a string of characters in a specified file. The text search pattern is called a regular expression. When it finds a match, it prints the line with the result.

Linux Course | Linux Tutorial | Linux For Beginners | Intellipaat with Tech Mirrors

Shell Scripting Tutorial | Linux Tutorial | Shell Scripting Training | Intellipaat with Tech Mirrors

Unix Shell Crash Course || Unix Shell Tutorial for Beginners with Tech Mirrors

Read More:

file handling commands in linuxfile management commands in dos
file handling commands in unixfile and directory handling commands in unix
file handling commands in cfile handling commands in linux with examples
file handling commands in pythonunix file handling commands with examples
file handling commands in vbfile handling commands in windows
file handling commands in cmdfile handling commands in shell script
file management commands in linuxfile handling linux commands
file manipulation commands in linuxfile management commands linux
the file management commands arefile manipulation linux commands
a file manipulation commands that extractsfile processing commands in linux
file management commands controlled by the operating systemfile management commands in linux pdf
basic file handling commands in linuxfile management commands in linux with examples
visual basic file handling commandsfile handling commands in ubuntu
file management commands in windowsfile management commands in operating system
name 2 file management commands controlled by the operating systemfile handling unix commands