我是一名新的生物技术学生,正在研究编程作业的介绍,但我遇到了障碍。问题如下。
“(3) 在你的新“.bashrc1”文件中,每行中有多少以空格分隔的第二个条目中包含数字 0...9?将你的答案输出到一个新文件“.bashrc1.counts”以“数字,计数...”的形式(例如 0、12 ...)。
到目前为止我所做的是
more .bashrc1 | awk ‘{print $2}’ | grep –c “0..9” > .bashrc1.counts
我知道 grep 部分可能是错误的,有没有办法将它传递给一个范围?像
grep -c "0","1"... etc
还是我必须做
|grep -c "0"|grep -c "1"|
另外,我知道如何输出到文件,但是我究竟如何以这种方式格式化输出?我已经用尽了谷歌和我的讲义,似乎找不到任何与我的问题相关的信息。
编辑:我正在寻找的文件;只是带有一个添加别名的默认 .bashrc 文件的副本。
# Sample .bashrc for SuSE Linux
# Copyright (c) SuSE GmbH Nuernberg
# There are 3 different types of shells in bash: the login shell, normal shell
# and interactive shell. Login shells read ~/.profile and interactive shells
# read ~/.bashrc; in our setup, /etc/profile sources ~/.bashrc - thus all
# settings made here will also take effect in a login shell.
#
# NOTE: It is recommended to make language settings in ~/.profile rather than
# here, since multilingual X sessions would not work properly if LANG is over-
# ridden in every subshell.
# Some applications read the EDITOR variable to determine your favourite text
# editor. So uncomment the line below and enter the editor of your choice :-)
#export EDITOR=/usr/bin/vim
#export EDITOR=/usr/bin/mcedit
# For some news readers it makes sense to specify the NEWSSERVER variable here
#export NEWSSERVER=your.news.server
# If you want to use a Palm device with Linux, uncomment the two lines below.
# For some (older) Palm Pilots, you might need to set a lower baud rate
# e.g. 57600 or 38400; lowest is 9600 (very slow!)
#
#export PILOTPORT=/dev/pilot
#export PILOTRATE=115200
test -s ~/.alias && . ~/.alias || true
alias start = "ls ~"