Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- abc:123:myname:1231
- def:423324:arbitrary:value:string
- StackExchange:Unix:Linux
- #!/bin/bash
- key_word_I_am_looking_for=$1
- my_variable=`cat myfile.csv | awk -F: -v keyword="$key_word_I_am_looking_for" '( $1 == keyword )' END{print "$@" }'`
- echo "$my_variable"
- #!/bin/bash
- awk -F: -v keyword="$1" '$1 == keyword {$1=$1; print}' myfile.csv
- grep "^$1:" myfile.csv | tr ":" " "
- sed -n '/^def:/s/:/ /gp' myfile.csv
- sed -n "/^$1:/s/:/ /gp" myfile.csv
- $ python -c "import sys;
- with open(sys.argv[2]) as f:
- for line in f:
- if sys.argv[1] == line.split(':')[0]:
- print ' '.join(line.strip().split(':'))" def file
- def 423324 arbitrary value string
Add Comment
Please, Sign In to add comment