New answers tagged

2

help running provides some hints: There are step and next instuctions (and also nexti and stepi). (gdb) help next Step program, proceeding through subroutine calls. Usage: next [N] Unlike "step", if the current source line calls a subroutine, this command does not enter the subroutine, but instead steps over the call, in effect treating it as a single ...


4

We can walk or swim anywhere, so why do we bother with bicycles, cars, trains, boats, planes and other vehicles? Sure, walking or swimming can be tiring, but there is a huge advantage in not needed any extra equipment. For one thing, although bash is Turing-complete, it is not good at manipulating data other than integers (not too large), strings, (one-...


10

it seems Bash is a Turing-complete language The concept of Turing completeness is entirely separate from many other concepts useful in a language for programming in the large: usability, expressiveness, understandabilty, speed, etc. If Turing-completeness were all we required, we wouldn't have any programming languages at all, not even assembly language. ...


3

Some reasons not to use shell scripts for large programs, just off the top of my head: Most functions are done by forking off external commands, which is slow. In contrast, programming languages like Perl can do the equivalent of mkdir or grep internally. There's no easy way to access C libraries, or make direct system calls, which means that e.g. the ...


7

In increasing order of helpfulness: if you identify a bug, report it with as much relevant information as possible (to make it easy for the maintainers to reproduce and then fix). If you can read the source and identify where the bug occurs, include that information. If you are able to provide a patch that fixes the bug, include that (or open a pull ...


2

Cut the columns into two sets, one with the first column and the other one with column two and three. Transliterate the characters into digits in the second of these sets. Paste everything together again. On the command line: $ cat data Id_animal / Column1 / Column2 ID01 / A / B ID02 / B / A ID03 / C / A ID04 / A / G ABCG / G / G $ paste -d '/' <(cut -...


0

With perl you can apply trasnliterations to specific input colums using a map e.g. perl -F"/" -alne 'print join "/", @F[0], map { tr/ABCG/1234/; $_ } @F[1,2]' input For example, given input Id_animal / Column1 / Column2 ID01 / A / B ID02 / B / A AG02 / B / A ID03 / C / A ID04 / A / G then $ perl -F"/" -alne 'print $. == 1? $_ : join "/", @F[0], map { ...


2

Under the assumption that you only want to translate A, B, C, and G to 1, 2, 3, and 4, and that the first column never contains those letters, you could simplify bgStack15's answer to just: tr 'ABCG' '1234' < input > output


0

Adjust the variables as desired. Save this to a file, for example `/home/Amanda/script.sh #!/bin/sh infile=~/input.txt outfile=~/output.txt while read one two; do printf "%s %s\n" "${one}" "$( echo "${two}" | tr 'ABCG' '1234' )" done < ${infile} > ${outfile} Be sure to make the script executable: chmod +x /home/Amanda/script.sh


0

String multiplication trick based on this answer: http://stackoverflow.com/a/5349772/4082052 Use substitution to insert programmable number of dashes paste $(for i in {1..400}; do echo -n '- '; done) or paste $(printf -- "- %.s" {1..400}) To know why printf -- was used: Dashes in printf


0

For a file with 4 rows: paste $(for((i=1;i<4;i++)); do echo -n "- "; done; echo -n "-") < file



Top 50 recent answers are included