Bash Commands - the diff of > and >> # Use I/O Redirection to generate a log file

1.   >
# Redirect stdout to a file.
# Creates the file if not present, otherwise overwrites it.

2.   >>
# Redirect stdout to a file.
# Creates the file if not present, otherwise appends to it.

3. Usage

&>filename         # Redirect both stdout and stderr to file "filename."

                               # This operator is now functional, as of Bash 4, final release.

1>filename          # Redirect stdout to file "filename."

1>>filename       # Redirect and append stdout to file "filename."

2>filename         # Redirect stderr to file "filename."

2>>filename       # Redirect and append stderr to file "filename."

: > filename        # Clear the file,  create it if not present.


For example:

Write a script that upon invocation shows the time and date, lists all logged-in users, and gives the
system uptime. The script then saves this information to a logfile.


#!/bin/bash

LOGFILE=script.log
ERRORFILE=script.errors

date  1>$LOGFILE
logname  1>>$LOGFILE
uptime  1>>$LOGFILE

bad_command1 2>>$ERRORFILE
bad_command2 2>>$ERRORFILE
bad_command3

date  &>$LOGFILE
logname  &>>$LOGFILE
uptime  &>>$LOGFILE

bad_command4 &>>$LOGFILE


# end of file

Note: ERRORFILE=script.errors        # Right format.

          ERRORFILE  =  script.errors    # Wrong format! It will generate a error message.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
data_dir='/public/work/Personal/wuxu/qiantao_17' for file1 in ${data_dir}/*.fasta; do for file2 in ${data_dir}/*.fasta; do if [ "$file1" != "$file2" ]; then touch snp_indel.end.sh && cat snp_indel.end.sh && \ export PATH=/public/work/Personal/pangshuai/software/conda/miniconda3/bin/:${PATH} && \ nucmer --mum -t 8 -g 1000 -p ${file1##*/}.${file2##*/}.ref_based.nucmer $file1 $file2 && \ delta-filter -1 -l 200 ${file1##*/}.${file2##*/}.ref_based.nucmer.delta > ${file1##*/}.${file2##*/}.ref_based.nucmer.delta.filter && \ dnadiff -d ${file1##*/}.${file2##*/}.ref_based.nucmer.delta.filter -p ${file1##*/}.${file2##*/}.ref_based.nucmer && \ show-coords -rcloT ${file1##*/}.${file2##*/}.ref_based.nucmer.delta.filter > ${file1##*/}.${file2##*/}.ref_based.nucmer.delta.filter.coords && \ show-coords -THrd ${file1##*/}.${file2##*/}.ref_based.nucmer.delta.filter > ${file1##*/}.${file2##*/}.ref_based.nucmer.delta.filter.syri.coords && \ show-snps -ClrTH ${file1##*/}.${file2##*/}.ref_based.nucmer.delta.filter > ${file1##*/}.${file2##*/}.ref_based.nucmer.delta.filter.snp && \ show-diff ${file1##*/}.${file2##*/}.ref_based.nucmer.delta.filter > ${file1##*/}.${file2##*/}.ref_based.nucmer.delta.filter.inv && \ perl /public/work/Pipline/Structural_Variation/pipeline/2.1.1/bin/filter_the_MUmmer_SNP_file.pl ${file1##*/}.${file2##*/}.ref_based.nucmer.delta.filter.snp ${file1##*/}.${file2##*/}.ref_based.nucmer.delta.filter.snp.SNPs ${file1##*/}.${file2##*/}.ref_based.nucmer.delta.filter.snp.Insertions ${file1##*/}.${file2##*/}.ref_based.nucmer.delta.filter.snp.Deletions 10000000 && \ touch snp_indel.end.tmp && \ mv snp_indel.end.tmp snp_indel.end && \ sleep 10 fi done done ,增加一个判断,使/public/work/Personal/wuxu/qiantao_17路径下以.fasta结尾的文件两两一组不分前后只组合一次,然后再执行touch 后面的代码
06-03

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值