Sunteți pe pagina 1din 5

touch filename.

FOAM Create paraview readable file


from the output

help -m command Help

command --help Description of the


command's supported syntax and options

env List all enviroment


variables in the shell (terminal)

env | grep ^FOAM_ List environment variables


beginning FOAM_

echo $FOAM_SRC Return the value


(denoted by $...) of the FOAM_SRC environment varaible

pwd Print the current


directory (find out which directory you are in)

cd ~ Changes directory to
home directory (~ is a short-cut meaning $HOME)

cd constant Change to a directory


named constant in the current directory

cd .. Move up one directory

ls List files in the


current directory

ls /etc List files in


the /etc directory (a system directory)

ls -a List all files,


including hidden files beginning with ., e.g. .bashrc

ls -l List with long list


format that includes file ownership and permissions

ls -al List all files


with long list format

echo "Hello World" > file1.txt Create a new file file1.txt


containing the text Hello World

echo $MY_OTHER_HOME This shows you what the


variable MY_OTHER_HOME contains

mkdir newDir Create a new directory


newDir

cp file1.txt file2.txt Create a new file file2.txt


by copying file1.txt

cp -i file1.txt file2.txt Create a new file, if file2


already exists prompt the user before overwriting

cp file1.txt dir1 Copy the contents of


file1 (into a file named file1) inside of directory dir1

cp -R dir1 dir2 Copy the contents of the


directory dir1. If directory dir2 does not exist, it is created. Otherwise, it
creates a directory named dir1 within directory dir2

cp -r newDir1 newDir2 Copy directory and contents


(-r = recursively) of newDir1 to a new directory newDir2

cp newDir2/file2.txt file1.txt Copy file2.txt from newDir1


directory to file1.txt in the current directory

cp *.txt text_files Copy all files in the current


working directory with names ending with the characters ".txt" to an existing
directory named text_files

mv file2.txt newDir1/ Move file2.txt into newDir


directory

mv file1.txt file2.txt If file2 does not exist, then


file1 is renamed file2. If file2 exists, its contents are silently replaced with
the contents of file1

mv -i file1 file2 If file exists, user is


prompted before replacing

mv file1 file2 file3 dir1 The files file1, file2, file3


are moved to directory dir1. If dir1 does not exist, mv will exit with an error

mv dir1 dir2 If dir2 does not exist,


then dir1 is renamed dir2. If dir2 exists, the directory dir1 is moved within
directory dir2

mv my_dir ../*.bak my_new_dir Move the subdirectory my_dir


and all the files ending in ".bak" in the current working directory's parent
directory to an existing directory named my_new_dir

rm file3.txt Delete file3.txt

rm file1 file2 Delete file1 and file2

rm -i file1 file2 Like above however, since the


"-i" (interactive) option is specified, the user is prompted before each file is
deleted

rm -r dir1 dir2 Directories dir1 and dir2 are


deleted along with all of their contents

rm -rf newDir1 Delete newDir1 directory


and contents

rm *~ Delete all files


in the current working directory that end with the character "~". Some applications
create backup files using this naming scheme. Using this command will clean them
out of a directory

cat file1.txt Print the file1.txt file


to terminal
less $WM_PROJECT_DIR/Allwmake Scroll through the Allwmake file in
terminal; type <SPACE> to scroll, Q to quit

head -10 $WM_PROJECT_DIR/Allwmake Print the first 10 lines of


Allwmake

tail -5 $WM_PROJECT_DIR/Allwmake Print the last 10 lines of Allwmake

grep -h build $WM_PROJECT_DIR/Allwmake -h: Prints lines of file Allwmake


that contain the expression build

grep -h -i BuIlD $WM_PROJECT_DIR/Allwmake -i: Prints lines of file Allwmake that


contain BuIlD, ignoring upper/lower case

grep -l if $WM_PROJECT_DIR/Allwmake -l: Prints the filename Allwmake to


terminal if it contains the expression build

grep -H if $WM_PROJECT_DIR/Allwmake -H: Prints both filename and lines


of a file that contain an expression the expression

find $FOAM_SRC Prints all files,


directories and links in the OpenFOAM src directory (FOAM_SRC)

find $FOAM_SRC -name fvMesh.H Prints files and links (or


directories) named fvMesh.H in FOAM_SRC

find $FOAM_SRC -name fvMesh.H -type f Prints files only named fvMesh.H in
FOAM_SRC

find $FOAM_SRC -name fvMesh.H -type l Prints links only named fvMesh.H in
FOAM_SRC

find $FOAM_SRC -name "*.[CH]" -type f Prints files only ending .H or .C


in FOAM_SRC (* means any characters)

find $FOAM_SRC -name "*.C" | xargs grep -l -i kepsilon


Combining find and grep allows us to search for an expression in large number
of files. For example to search through all OpenFOAM .C source files to find one
containing the expression kepsilon (case insensitive)

find $FOAM_SRC -name "*.C" -exec grep -l -i kepsilon {} \; An


alternative syntax, that executes slower

I/O Redirection:

ls > file_list.txt Most command line


programs that display their results do so by sending their results to a facility
called standard output. By default, standard output directs its contents to the
display. To redirect standard output to a file, the ">" character is used.
Repetitive use results in overwriting the output file.

ls >> file_list.txt Standard output is redirected


to the file. When the results are appended, the new results are added to the end of
the file

sort < file_list.txt Redirect standard input from


a file instead of the keyboard
sort < file_list.txt > sorted_file_list.txt Redirect standard input and output.
Redirection operators (the "<" and ">") must appear after the other options and
arguments in the command

Pipelines:

ls -lt | head Displays the 10 newest


files in the current directory

find . -type f -print | wc -l Displays the total number of


files in the current working directory and all of its subdirectories

Filters:

sort Sorts standard input


then outputs the sorted result on standard output

uniq Given a sorted stream of


data from standard input, it removes duplicate lines of data (i.e., it makes sure
that every line is unique)

grep Examines each line of


data it receives from standard input and outputs every line that contains a
specified pattern of characters

fmt Reads text from standard


input, then outputs formatted text on standard output

pr Takes text input


from standard input and splits the data into pages with page breaks, headers and
footers in preparation for printing

head Outputs the first few


lines of its input. Useful for getting the header of a file

tail Outputs the last few


lines of its input. Useful for things like getting the most recent entries from a
log file

tr Translates
characters. Can be used to perform tasks such as upper/lowercase conversions or
changing line termination characters from one type to another (for example,
converting DOS text files into Unix style text files)

sed Stream editor. Can


perform more sophisticated text translations than tr

awk An entire programming


language designed for constructing filters. Extremely powerful

icoFoam > log & Run as background process


cat log

foamCloneCase -latestTime dir1 dir2 Use the -latestTime option to copy


the latest time directory. Copy dir1 and make dir2.

mkdir -p $FOAM_RUN
cp -r $FOAM_TUTORIALS/incompressible/icoFoam/cavity/cavity .
cd $FOAM_RUN
cd cavity
blockMesh
icoFoam

mkdir -p $FOAM_RUN
cp -r $FOAM_TUTORIALS $FOAM_RUN

cd workingDir
cp -ar $FOAM_TUTORIALS/incompressible/icoFoam/cavity/cavity .
cd cavity
blockMesh
icoFoam

foamCloneCase -latestTime cavity cavityHighRe

"When I meet God, I am going to ask him two questions: Why relativity? And why
turbulence? I really believe he will have an answer for the first."
Werner Heisenberg

cp -ar $FOAM_TUTORIALS/multiphase/interFoam/RAS/DTCHull .

S-ar putea să vă placă și