Tag Info

Hot answers tagged

4

The field separator of the split function is a regular expression, so you can split on = OR ;. If you know that $9 begins with "ID=", then awk -v OFS='\t' ' $3 == "gene" { split($9, id, /[=;]/) print $1, $4, $5, id[2], $6, $7 } ' genes.gff3 If "ID=" is not necessarily at the beginning of the field, then there's a little more work ...


3

-c means that you want to know the number of times this user is in /etc/passwd, while $? is the exit code. Those are differents, since the number of times is printed on stdout. Use $() for getting stdout into a variable Second problem: all your variables, like $uzer will not be substituted with their values when in single quotes. Use double quotes. ...


2

This is a Bash solution, as allowed me to publish, despite the explicit request asking to use awk and sed: show_genes() { local filename="$1" while read -ra larr; do if [[ ${larr[2]} = gene ]]; then larr[8]="${larr[8]%%;*}" larr[8]="${larr[8]#ID=}" printf '%s\n' "${larr[*]}" fi done < ...


2

grep '^[dD][aeiou]..s$' /usr/share/dict/words ^[dD] - match d or D at the beginning of the line [aeiou] - match a, e, i, o or u .. - match any two characters s$ - match s, followed by the end of the line


1

1st attempt (didn't work) You need to include the directories in addition to the files: rsync -zavC --delete --include '*/' --include='*.php' --include='*.js' \ --exclude="*" /media/datacod/Test/ /home/lucas/Desktop/rsync/ 2nd attempt rsync -avzC --filter='-rs_*/.svn*' --include="*/" --include='*.js' \ --include='*.php' --exclude="*" --delete ...


1

if expr ".$IP_ADDRESS" : '\(\.[0-9]\{1,3\}\)\{3,4\}$' > /dev/null then echo match else echo no match fi You can't use grep here because grep is used to match lines, not strings. You can't use echo either as it does substitutions on its arguments. You can't leave variables unquoted either as otherwise filename generation and word splitting occurs. ...


1

You could split the field and use substr by: split($9, a, ";") print substr(a[1], 4) Awk indexes start at 1. Another option could be to modify the input field separator (FS). FS is space, " ", by default – which also has the special effect of ignoring leading and trailing spaces. Also, instead of using print $1, \t, ... or the printf variant one could ...



Only top voted, non community-wiki answers of a minimum length are eligible