New answers tagged

3

head prints 10 lines by default, but it reads in as much input as it can while doing so - note that GNU head has options which require it to know how many lines there are in the file in total, so reading in as much as it can is not wrong. head reads in as much as it can to fill its buffer, which seems to be 8192 bytes: ~ seq 10000 | strace -fe read ...


0

If you treat 0 as valid input you may use single regex: while true; do echo -n "Enter a number: " read num if ! [[ $num =~ ^[0-9]+\.?[0-9]*$ ]]; then echo "You have to provide positive integer or float...Try again" else echo "Looks good!" break fi done #The rest of your code Otherwise you need to add ...


0

This works in most of sh-shells (ksh/bash/zsh/...) while echo -n "Int:" read num do [ "$num" = "" ] && echo "not integer" && continue s=${num//[0-9]/} # remove all numbers # if string still include something = it wasn't >=0 int [ "$s" != "" ] && echo "Not integer" && continue # integer, break loop ...


0

You can use regular expressions to precisely validate the input. For example in bash/zsh the following will work: read k while ! [[ "$k" =~ "[0-9]+\.[0-9]+" ]]; do echo 'Invalid number format, Re-enter a number' read k done


1

This can be done easily with a couple of common utilities: cut -d : -f 1 input.txt | uniq cut extracts fields from the input file. -d denotes the delimiter character (in this case a :), and -f 1 says to extract the first field. uniq removes repeated adjacent lines from the input


0

Since all of my results had the same format (The file's were in the src/ directory) I was able to use the following command: cat input.txt | tr ':' '\n' | grep 'src/' | uniq


0

You can try this solution: TODO for clickpad to work with the LED : (Enable the proposed archive for Ubuntu 12.04 : https://wiki.ubuntu.com/Testing/EnableProposed After dist-upgrade, do this :) Build a xserver-xorg-input-synaptics with led support package : mkdir tmpbuild cd tmpbuild apt-get source xserver-xorg-input-synaptics d cd ...



Top 50 recent answers are included