Example of bash read and write files in Linux

Source: Internet
Author: User
Tags arithmetic builtin hash


#!/bin/bash

#读取文件内容到变量中

Filecontent= ' Cat ~/file.txt ' is the TAB key on that
Echo $filecontent

#取得文件内容的每一行

For Fileline in $filecontent
Todo
Echo $fileline
Done

#写内容到文件中

echo $filecontent >> test.txt

Bash built-in UNIX command

.: Executes the program in the current process environment. With source.
. The File:dotunix command reads the commands from file files and executes them.
: null operation, return exit status 0.

Alias: Displays and creates an alias for an existing UNIX command.
BG: Put your homework in the background.
Bind: Displays the binding of the current keyword to the function, or binds the keyword to the ReadLine function or macro.
Break: Jump out of the loop from the most inner layer.
Builtin [Sh-builtin [args]]: runs a built-in Shellunix command and transmits parameters, returning exit status 0. This UNIX command is useful when a function has the same name as a built-in UNIX command.
CD [ARG]: Change the directory, if not with parameters, back to the home directory, with parameters switch to the directory referred to by the parameter.
Command COMAND [ARG]: Executes the UNIX command even if there is a function of the same name. In other words, skip function lookup.
DECLARE [VAR]: Displays all variables, or declares variables with optional attributes.
Dirs: Displays the directory of the current record (the result of the pushd).
Disown: Deletes an active job from the job table.
echo [args]: Displays the args and wraps the line.
Enable: Enables or disables the Unix command that is built into the shell.
eval [args]: Read the args into the shell and execute the generated UNIX command.
EXEC command: Run UNIX command to replace the current shell.
Exit [n]: Exit shell with State N.
Export [var]: Make variables available for quilt identification.
FC: Historical Modification of UNIX commands, for Editing historical UNIX commands.
FG: Put the backstage work on the front desk.
getopts: Resolves and processes Unix command-line options.
Hash: Controls the internal hash table used to speed up Unix command lookups.
Help [command]: Displays useful information about the built-in UNIX commands. If a UNIX command is specified, details of the UNIX command are displayed.
History: Displays a list of Unix command histories with line numbers.
Jobs: Show jobs in the background.
Kill [-signal Process]: sends a signal to a process specified by the PID number or job number. Enter Kill-l to view the list of signals.
Let: used to compute the value of an arithmetic expression and assign the result of an arithmetic operation to a variable.
Local: Use in a function to limit the scope of a variable to within a function.
Logout: Exit login shell.
POPD: Deletes an item from the catalog stack.
PUSHD: Adds an entry to the catalog stack.
PWD: Print out the current working directory.
Read [VAR]: reads a row from the standard input and saves it to the variable var.
ReadOnly [var]: Sets the variable var to read-only and does not allow resetting of the variable.
return [n]: Exit from function, n is the exit state value assigned to the Returnunix command.
Set: Sets options and positional parameters.
Shift [n]: shifts the position parameter to the left N times.
Stop PID: Pauses the operation of the first PID number process.
Suspend: Terminates the current Shell's operation (invalid for the login shell).
Test: Check the file type and evaluate the conditional expression.
Times: Displays the cumulative user time and system time of the running of processes initiated by the current shell.
Trap [ARG] [n]: performs ARG when the shell receives a signal n (n is 0, 1, 2, or 15).
Type [command]: Displays the types of UNIX commands, such as: PWD is a built-in UNIX command for the shell.
Typeset: With declare. Set variables and give them properties.
Ulimit: Displays or sets the maximum amount of resources available for the process.
Umask [octal number]: User file creation pattern masks for owners, groups, and other users.
Unalias: Cancels all Unix command alias settings.
unset [name]: Cancels the definition of the value or function of the specified variable.
Wait [pid#n]: The background process waits for the PID number N to end and reports its end state.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.