bchikLnNprsvz什么意思

Linux系统中file命令的使用详解
作者:潇湘隐者
字体:[ ] 来源:cnblogs 时间:10-14 12:10:36
这篇文章主要介绍了Linux系统中file命令的使用详解,是Linux入门学习中的基础知识,需要的朋友可以参考下
命令简介:
该命令用来识别文件类型,也可用来辨别一些文件的编码格式。它是通过查看文件的头部信息来获取文件类型,而不是像Windows通过扩展名来确定文件类型的。
执行权限 :All User
指令所在路径:/usr/bin/file
&命令语法:代码如下:file [ -bchikLnNprsvz ] [ -f namefile ] [ -F separator ] [ -m magicfiles ] file ...
命令参数:
下表列出了部分常用的参数。
使用示例: 1:查看file命令的帮助信息
代码如下:[root@DB-Server ~]# file --helpUsage: file [OPTION]... [FILE]...Determine file type of FILEs.&&
-m, --magic-file LIST&&&&& use LIST as a colon-separated list of magic&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& number files& -z, --uncompress&&&&&&&&&& try to look inside compressed files& -b, --brief&&&&&&&&&&&&&&& do not prepend filenames to output lines& -c, --checking-printout&&& print the parsed form of the magic file, use in&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& conjunction with -m to debug a new magic file&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& before &installing it& -f, --files-from FILE&&&&& read the filenames to be examined from FILE& -F, --separator string&&&& use string as separator instead of `:'& -i, --mime&&&&&&&&&&&&&&&& output mime type strings& -k, --keep-going&&&&&&&&&& don't stop at the first match& -L, --dereference&&&&&&&&& causes symlinks to be followed& -n, --no-buffer&&&&&&&&&&& do not buffer output& -N, --no-pad&&&&&&&&&&&&&& do not pad output& -p, --preserve-date&&&&&&& preserve access times on files& -r, --raw&&&&&&&&&&&&&&&&& don't translate unprintable chars to \ooo& -s, --special-files&&&&&&& treat special (block/char devices) files as&&&&&&&&&&&&&&&&&&&&&&&&&&&& ordinary ones&&&&& &--help&&&&&&&&&&&&&&&& display this help and exit&&&&& &--version&&&&&&&&&&&&& output version information and exit当然你也可以使用 man file 获取更加详细的帮助文档信息。
2:不输出文件名称,只显示文件格式以及编码通过下面两个命令对时,就可以清晰的了解参数-b的作用。&代码如下:[root@DB-Server ~]# file Temp.txt Temp.txt: UTF-8 Unicode text, with very long lines, with CRLF line terminators[root@DB-Server ~]# file -b Temp.txtUTF-8 Unicode text, with very long lines, with CRLF line terminators3: 输出mime类型的字符串&代码如下:[root@DB-Server ~]# file -i Temp.txt Temp.txt: text/ charset=utf-8 &
4: 查看文件中的文件名的文件类型
这个参数非常适合shell脚本去查找、判别某种文件类型的数据。&
你可以像下面这样使用 file 命令确定文件的类型。下面的截图显示了用 file 命令确定不同文件类型的例子。代码如下:tecmint@tecmint ~/Linux-Tricks $ dirBACKUP
master.zipcrossroads-stable.tar.gz
num.txtEDWARD-MAYA--NEW-REMIX.mp3
reggea.xspfLinux-Security-Optimization-Book.gif
tmp-linktecmint@tecmint ~/Linux-Tricks $ file BACKUP/BACKUP/: directory tecmint@tecmint ~/Linux-Tricks $ file master.zip master.zip: Zip archive data, at least v1.0 to extracttecmint@tecmint ~/Linux-Tricks $ file crossroads-stable.tar.gzcrossroads-stable.tar.gz: gzip compressed data, from Unix, last modified: Tue Apr
5 15:15:20 2011tecmint@tecmint ~/Linux-Tricks $ file Linux-Security-Optimization-Book.gif Linux-Security-Optimization-Book.gif: GIF image data, version 89a, 200 x 259tecmint@tecmint ~/Linux-Tricks $ file EDWARD-MAYA--NEW-REMIX.mp3 EDWARD-MAYA--NEW-REMIX.mp3: Audio file with ID3 version 2.3.0, contains: MPEG ADTS, layer III, v1, 192 kbps, 44.1 kHz, JntStereotecmint@tecmint ~/Linux-Tricks $ file /dev/sda1/dev/sda1: block special tecmint@tecmint ~/Linux-Tricks $ file /dev/tty1/dev/tty1: character special
5:尝试去解读压缩文件的内容&代码如下:[root@DB-Server ~]# file -z Temp.txt.gz Temp.txt.gz: UTF-8 Unicode text, with very long lines, with CRLF line terminators (gzip compressed data, was "Temp.txt", from Unix, last modified: Tue Jun 24 00:34:15 2014)[root@DB-Server ~]# &
6: 查看软链接对应文件的文件类型
如下所示,创建一个软链接sfile,然后分别用file 和带参数的file -L查看代码如下:[root@DB-Server ~]# ln -s Temp.txt.gz sfile[root@DB-Server ~]# file sfile sfile: symbolic link to `Temp.txt.gz'[root@DB-Server ~]# file -L sfile sfile: gzip compressed data, was "Temp.txt", from Unix, last modified: Tue Jun 24 00:34:15 2014[root@DB-Server ~]#
大家感兴趣的内容
12345678910
最近更新的内容今天看啥 热点:
Linux系统中file命令的使用详解,linux命令的使用这篇文章主要介绍了Linux系统中file命令的使用详解,是Linux入门学习中的基础知识,需要的朋友可以参考下
命令简介:
该命令用来识别文件类型,也可用来辨别一些文件的编码格式。它是通过查看文件的头部信息来获取文件类型,而不是像Windows通过扩展名来确定文件类型的。
执行权限 :All User
指令所在路径:/usr/bin/file
&命令语法:代码如下:file [ -bchikLnNprsvz ] [ -f namefile ] [ -F separator ] [ -m magicfiles ] file ...
命令参数:
下表列出了部分常用的参数。
使用示例: 1:查看file命令的帮助信息
代码如下:[root@DB-Server ~]# file --helpUsage: file [OPTION]... [FILE]...Determine file type of FILEs.&&
-m, --magic-file LIST&&&&& use LIST as a colon-separated list of magic&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& number files& -z, --uncompress&&&&&&&&&& try to look inside compressed files& -b, --brief&&&&&&&&&&&&&&& do not prepend filenames to output lines& -c, --checking-printout&&& print the parsed form of the magic file, use in&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& conjunction with -m to debug a new magic file&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& before &installing it& -f, --files-from FILE&&&&& read the filenames to be examined from FILE& -F, --separator string&&&& use string as separator instead of `:'& -i, --mime&&&&&&&&&&&&&&&& output mime type strings& -k, --keep-going&&&&&&&&&& don't stop at the first match& -L, --dereference&&&&&&&&& causes symlinks to be followed& -n, --no-buffer&&&&&&&&&&& do not buffer output& -N, --no-pad&&&&&&&&&&&&&& do not pad output& -p, --preserve-date&&&&&&& preserve access times on files& -r, --raw&&&&&&&&&&&&&&&&& don't translate unprintable chars to \ooo& -s, --special-files&&&&&&& treat special (block/char devices) files as&&&&&&&&&&&&&&&&&&&&&&&&&&&& ordinary ones&&&&& &--help&&&&&&&&&&&&&&&& display this help and exit&&&&& &--version&&&&&&&&&&&&& output version information and exit当然你也可以使用 man file 获取更加详细的帮助文档信息。
2:不输出文件名称,只显示文件格式以及编码通过下面两个命令对时,就可以清晰的了解参数-b的作用。&代码如下:[root@DB-Server ~]# file Temp.txt Temp.txt: UTF-8 Unicode text, with very long lines, with CRLF line terminators[root@DB-Server ~]# file -b Temp.txtUTF-8 Unicode text, with very long lines, with CRLF line terminators3: 输出mime类型的字符串&代码如下:[root@DB-Server ~]# file -i Temp.txt Temp.txt: text/ charset=utf-8 &
4: 查看文件中的文件名的文件类型
这个参数非常适合shell脚本去查找、判别某种文件类型的数据。&
你可以像下面这样使用 file 命令确定文件的类型。下面的截图显示了用 file 命令确定不同文件类型的例子。代码如下:tecmint@tecmint ~/Linux-Tricks $ dirBACKUP
master.zipcrossroads-stable.tar.gz
num.txtEDWARD-MAYA--NEW-REMIX.mp3
reggea.xspfLinux-Security-Optimization-Book.gif
tmp-linktecmint@tecmint ~/Linux-Tricks $ file BACKUP/BACKUP/: directory tecmint@tecmint ~/Linux-Tricks $ file master.zip master.zip: Zip archive data, at least v1.0 to extracttecmint@tecmint ~/Linux-Tricks $ file crossroads-stable.tar.gzcrossroads-stable.tar.gz: gzip compressed data, from Unix, last modified: Tue Apr
5 15:15:20 2011tecmint@tecmint ~/Linux-Tricks $ file Linux-Security-Optimization-Book.gif Linux-Security-Optimization-Book.gif: GIF image data, version 89a, 200 x 259tecmint@tecmint ~/Linux-Tricks $ file EDWARD-MAYA--NEW-REMIX.mp3 EDWARD-MAYA--NEW-REMIX.mp3: Audio file with ID3 version 2.3.0, contains: MPEG ADTS, layer III, v1, 192 kbps, 44.1 kHz, JntStereotecmint@tecmint ~/Linux-Tricks $ file /dev/sda1/dev/sda1: block special tecmint@tecmint ~/Linux-Tricks $ file /dev/tty1/dev/tty1: character special
5:尝试去解读压缩文件的内容&代码如下:[root@DB-Server ~]# file -z Temp.txt.gz Temp.txt.gz: UTF-8 Unicode text, with very long lines, with CRLF line terminators (gzip compressed data, was "Temp.txt", from Unix, last modified: Tue Jun 24 00:34:15 2014)[root@DB-Server ~]# &
6: 查看软链接对应文件的文件类型
如下所示,创建一个软链接sfile,然后分别用file 和带参数的file -L查看代码如下:[root@DB-Server ~]# ln -s Temp.txt.gz sfile[root@DB-Server ~]# file sfile sfile: symbolic link to `Temp.txt.gz'[root@DB-Server ~]# file -L sfile sfile: gzip compressed data, was "Temp.txt", from Unix, last modified: Tue Jun 24 00:34:15 2014[root@DB-Server ~]#
相关搜索:
相关阅读:
相关频道:
&&&&&&&&&&&&&&&&
LINUX系统最近更新君,已阅读到文档的结尾了呢~~
ubuntu单机wrf安装,ubuntu 安装,ubuntu u盘安装,ubuntu安装教程,硬盘安装ubuntu,ubuntu 安装jdk,ubuntu 安装mysql,vmware安装ubuntu,ubuntu ssh 安装,虚拟机安装ubuntu
扫扫二维码,随身浏览文档
手机或平板扫扫即可继续访问
ubuntu单机wrf安装
举报该文档为侵权文档。
举报该文档含有违规或不良信息。
反馈该文档无法正常浏览。
举报该文档为重复文档。
推荐理由:
将文档分享至:
分享完整地址
文档地址:
粘贴到BBS或博客
flash地址:
支持嵌入FLASH地址的网站使用
html代码:
&embed src='/DocinViewer--144.swf' width='100%' height='600' type=application/x-shockwave-flash ALLOWFULLSCREEN='true' ALLOWSCRIPTACCESS='always'&&/embed&
450px*300px480px*400px650px*490px
支持嵌入HTML代码的网站使用
您的内容已经提交成功
您所提交的内容需要审核后才能发布,请您等待!
3秒自动关闭窗口Command-cat, tac, file, history, tree,tee…-学网-中国IT综合门户网站-提供健康,养生,留学,移民,创业,汽车等信息
Command-cat, tac, file, history, tree,tee…
来源:互联网 更新时间: 14:36:00 责任编辑:鲁晓倩字体:
tac C 将每个指定文件按行倒置并写到标准输出。如果不指定文件,或文件为”-“,则从标准输入读取数据,不常用#SYNOPSIS
tac&[OPTION]...&[FILE]...
##&-b,&--before&在行前而非行尾添加分隔标志
##&-r,&--regex&将分隔标志视作正则表达式来解析
##&-s,&--separator=字符串&&使用指定字符串代替换行作为分隔标志
$filefile C 检查文件的类型#SYNOPSIS
file&[-bchikLNnprsvz0]&[--apple]&[--mime-encoding]&[--mime-type]&[-e&testname]&[-F&separator]&[-f&namefile]&[-m&magicfiles]&file&...
file&-C&[-m&magicfiles]
file&[--help]
##&-b&--brief&简短模式,&不输出文件名
$&file&-b&test
--&&ASCII&English&text
##&待续...historyhistory C 显示或操纵历史列表。#SYNOPSIS
history&[-c]&[-d&offset]&[n]
history&-anrw&[filename]
history&-ps&arg&[arg...]
##&-c&清空历史记录
##&-a:&当缓冲区中的历史手动追加文件;
##&n&数字,要列出最近的&n&笔命令列表
$&history&4
--&&849&&history&-n
&&&&850&&history
&&&&851&&history&-n
&&&&852&&history&4
##&-r&将&histfiles&的内容读到目前这个&shell&的&history&记忆中
##&-w&将目前的&history&记忆内容写入&histfiles
##&-d&#:&删除历史中指定的命令
##&执行history列表中命令的方法
##&调用过去执行过的命令:
##&&&&&&&&&!#:调用历史中的第#条命令;
##&&&&&&&&&!!:&重复执行上一条命令
##&&&&&&&&&!string:调用历史中最近一个以string开头的命令;
##&调用过去执行过的命令的最后一个参数:
##&&&&&&&&&!$:
##&&&&&&&&&ESC,&.
##&&&&&&&&&Alt+.tree
相关文章:
上一篇文章:下一篇文章:
最新添加资讯
24小时热门资讯
Copyright © 2004- All Rights Reserved. 学网 版权所有
京ICP备号-1 京公网安备02号23:21:16 | |
本帖最后由 ztftom 于
08:52 编辑 转载请注明出自“气象家园”最近看到a版发贴讨论WRF在Ubuntu上的安装,正好家里的电脑是Ubuntu系统,而且也想装个WRF,就尝试了一下。这里用的编译器是gfortran和gcc。这两个都是GNU软件,可以免费下载。(PGI好像不是免费的,ifort和icc有免费版本)注意: 因为这台实验电脑上只有gfortran和gcc作为fortran和C编译器,所以让事情变简单了很多。根据我的经验,如果电脑上安装多个编译器的话,会需要一些进一步的设定,特别是在安装NETCDF的时候。这篇文章暂不考虑这个问题。注意:这篇文章只是测试了WRF的安装,没有涉及WPS和NCL的安装。会在另外的帖子中讨论它们的安装。在下面文章中,使用以下设定,大家可以根据情况修改:WRF安装路径:/home/ztftom/WRFNETCDF安装路径: /home/ztftom/util/netcdf1. 确认安装gfortran, gccgfortran是fortran编译器,gcc是C编译器。这两个必须在电脑上安装的有。可以用以下命令检查。$which gfortran$which gcc如果两个编译器已经安装,将会返回这两个命令所在的位置。否则什么也不返回。如果没有安装,那么可以到Ubuntu软件中心搜索安装,或者用以下命令安装$sudo apt-get install gfortran$sudo apt-get install gcc2. 安装netcdf到Unidata找到安装文件,下载:$tar -xvf netcdf-4.1.3.tar.gz 进入解压缩后得到的文件夹,./configure --disable-dap --disable-netcdf-4 --prefix=/home/ztftom/util/netcdf注意:上面红色高亮的两个选项是很多次实验后证明必须的。--disable-dap的原因是缺少一个‘curl’的lib, --disable-netcdf-4是因为WRF暂时不支持netcdf 4之后,运行:$make$make install(其实ubuntu的软件管理里可以找到netcdf的下载,我是自己安装了之后发现的:$sudo apt-get install netcdf-bin我没有尝试,如果大家哪位适用了的话可否告诉我效果如何?)2. 下载WRF ARW V3.3网址: 需要注册,才能下载,下载到的文件名为:WRFV3.3.TAR.gz解压缩文件:$tar -xvf WRFV3.3.TAR.gz解压缩后,有WRFV3文件夹,进入该文件夹。3. 设置.bashrc$vi ~/.bashrc& && & # 这个也可以用gedit 在该文件末尾加上:export NETCDF=/home/ztftom/util/netcdf&&& && && & # 根据WRF手册,这个变量必须设置export WRFIO_NCD_LARGE_FILE_SUPPORT=1& && &&&# 这个是根据WRF手册推荐添加的,允许WRF大文件IO(& 2G)#以下三个设置是因为没有将NETCDF放在标准的软件安装位置而必须添加的(一般ubuntu会把软件安装在/usr或者/user/local)export PATH=.:$NETCDF/bin:$PATHexport LD_LIBRARY_PATH=${NETCDF}/lib:${LD_LIBRARY_PATH} export LD_RUN_PATH=${NETCDF}/lib:${LD_RUN_PATH}返回shell, 用以下命令让修改生效:$source ~/.bashrc这个时候,可以使用ncdump命令来检测NETCDF是否安装成功(因为NETCDF已经添加到PATH变量中):$ncdump如果netcdf安装成功,会返回:ncdump [-c|-h] [-v ...] [[-b|-f] [c|f]] [-l len] [-n name] [-p n[,n]] [-k] [-x] [-s] [-t] [-w] file&&[-c]& && && && & Coordinate variable data and header information&&[-h]& && && && & Header information only, no data&&[-v var1[,...]]&&Data for variable(s) &var1&,... only&&[-b [c|f]]& && & Brief annotations for C or Fortran indices in data&&[-f [c|f]]& && & Full annotations for C or Fortran indices in data&&[-l len]& && && &Line length maximum in data section (default 80)&&[-n name]& && &&&Name for netCDF (default derived from file name)&&[-p n[,n]]& && & Display floating-point values with less precision&&[-k]& && && && & Output kind of netCDF file&&[-x]& && && && & Output XML (NcML) instead of CDL&&[-s]& && && && & Output special (virtual) attributes&&[-t]& && && && & Output time data as date-time strings&&[-w]& && && && & Without client-side caching of variables for DAP URLs&&file& && && && & Name of netCDF filenetcdf library version 4.1.3 of Oct&&9 :03 $4. Configure 在WRFV3目录下,运行:$./configure会得到:checking for perl5... nochecking for perl... found /usr/bin/perl (perl)Will use NETCDF in dir: /home/ztftom/util/netcdfPHDF5 not set in environment. Will configure WRF for use without.$JASPERLIB or $JASPERINC not found in environment, configuring to build without grib2 I/O...------------------------------------------------------------------------Please select from among the following supported platforms.& &1.&&Linux i486 i586 i686, gfortran compiler with gcc&&(serial)& &2.&&Linux i486 i586 i686, gfortran compiler with gcc&&(smpar)& &3.&&Linux i486 i586 i686, gfortran compiler with gcc&&(dmpar)& &4.&&Linux i486 i586 i686, gfortran compiler with gcc&&(dm+sm)& &5.&&Linux i486 i586 i686, g95 compiler with gcc&&(serial)& &6.&&Linux i486 i586 i686, g95 compiler with gcc&&(dmpar)& &7.&&Linux i486 i586 i686, PGI compiler with gcc&&(serial)& &8.&&Linux i486 i586 i686, PGI compiler with gcc&&(smpar)& &9.&&Linux i486 i586 i686, PGI compiler with gcc&&(dmpar)&&10.&&Linux i486 i586 i686, PGI compiler with gcc&&(dm+sm)&&11.&&Linux x86_64 i486 i586 i686, ifort compiler with icc&&(serial)&&12.&&Linux x86_64 i486 i586 i686, ifort compiler with icc&&(smpar)&&13.&&Linux x86_64 i486 i586 i686, ifort compiler with icc&&(dmpar)&&14.&&Linux x86_64 i486 i586 i686, ifort compiler with icc&&(dm+sm)&&15.&&Linux i486 i586 i686 x86_64, PathScale compiler with pathcc&&(serial)&&16.&&Linux i486 i586 i686 x86_64, PathScale compiler with pathcc&&(dmpar)选择 1,gfortran和gcc,单处理器。然后会显示:Compile for nesting? (0=no nesting, 1=basic, 2=preset moves, 3=vortex following) [default 0]: 为了调试方便,选择 0, 无嵌套。之后会显示配置文件, 在显示配置文件之后,如果没有问题的话,会返回:Settings listed above are written to configure.wrf.If you wish to change settings, please edit that file.If you wish to change the default options, edit the file:& &&&arch/configure_new.defaults&&Testing for NetCDF, C and Fortran compilerThis installation NetCDF is 32-bitC compiler is 32-bitFortran compiler is 32-bitIt will build in 32-bit===================================================这里报告一个BUG,如果没有上面的显示,而是如下显示:Settings listed above are written to configure.wrf.If you wish to change settings, please edit that file.If you wish to change the default options, edit the file:& &&&arch/configure_new.defaults&&mktemp: 模板"foo_13562" 中X 太少Testing for NetCDF, C and Fortran compilerno entry netcdf.o in archiveUsage: file [-bchikLNnprsvz0] [--apple] [--mime-encoding] [--mime-type]& && && && &[-e testname] [-F separator] [-f namefile] [-m magicfiles] file ...& && & file -C [-m magicfiles]& && & file [--help]Usage: file [-bchikLNnprsvz0] [--apple] [--mime-encoding] [--mime-type]& && && && &[-e testname] [-F separator] [-f namefile] [-m magicfiles] file ...& && & file -C [-m magicfiles]& && & file [--help]&&One of compilers testing failed!&&Please check your compiler同时,你会发现WRFV3文件夹下有些文件被删除了那么请修改configure文件$vi configure找到:foo=`mktemp foo_$$`修改为foo=`mktemp foo_$$.XXXXXX`原因是ubuntu上的mktemp只接收filename.XXX... 形式的输入 暂时不确定是否所有Linux上都有这个问题,因为之前用OPENSUSE时记得没有这个问题。欢迎大家继续在该贴汇总该问题。做了以上修改后,可能会有另一个BUGSettings listed above are written to configure.wrf.If you wish to change settings, please edit that file.If you wish to change the default options, edit the file:& &&&arch/configure_new.defaults&&Testing for NetCDF, C and Fortran compilerno entry netcdf.o in archiveThis installation NetCDF isC compiler is 32-bitFortran compiler is 32-bitIt will build in注意其中的no entry netcdf.o in archive这个问题其实完全可以忽略。因为有的版本的NETCDF有这个netcdf.o,有的没有,但都不影响运行。但你可以修正问题:$vi configure找到& & ar p $NETCDF/lib/libnetcdf.a netcdf.o & ${foo}.o修改为& & ar p $NETCDF/lib/libnetcdf.a & ${foo}.o=================================================================5. Compile$./compile case && logcase是test文件夹下任何一个文件夹名(代表了不同的case,详见WRF的Manual)比如$./compile em_seabreeze2d_x && log完成后,检查log文件是否有"Error"(中文版ubuntu的话是“错误”)如果有Error的话,继续debug===============================================================这里再报告一个Bug,有可能/bin/sh没有安装m4,需要安装m4。 如果没有安装,在编译过程中,会显示:/bin/sh: m4: not found===============================================================另外,检查main文件夹里是否有ideal.exe和wrf.exe(如果是em_real的case的话,是real.exe和wrf.exe)6. 运行model,根据结果检测。如何运行WRF,请参照WRF Manual, Manual可以到 下载pdf运行wrf.exe,如果最后返回wrf: SUCCESS COMPLETE WRF则基本可以确定WRF已经成功安装。此外还可以检查WRF的输出,不再赘述。
阅读(...) 评论()
Copyright & catherin
Powered by:
模板提供:

我要回帖

更多关于 prg18bc2r2mm1rb 的文章

 

随机推荐