bash script use cut command at variable and store result at another variable

The awk solution is what I would use, but if you want to understand your problems with bash, here is a revised version of your script. #!/bin/bash -vx ##config file with ip addresses like 10.10.10.1:80 file=config.txt while read line ; do ##this line is not correct, should strip :port and store to ip var ip=$( … Read more

Using bash ps and cut together

ps is printing out space separators, but cut without -d uses the tab character. The tr -s squeezes the spaces together to get more of the separation that you want, but remember that there is the initial set of spaces (squeezed to one) hence why you need to add 1 to each field. Also, there … Read more

Printing only the first field in a string

You can do this easily with a variety of Unix tools: $ cut -d’ ‘ -f1 <<< “12/12/2013 14:32” 12/12/2013 $ awk ‘{print $1}’ <<< “12/12/2013 14:32” 12/12/2013 $ sed ‘s/ .*//’ <<< “12/12/2013 14:32” 12/12/2013 $ grep -o “^\S\+” <<< “12/12/2013 14:32” 12/12/2013 $ perl -lane ‘print $F[0]’ <<< “12/12/2013 14:32” 12/12/2013

cutting a string into several lines in bash

This should do the trick pwd | tr “https://stackoverflow.com/” ‘\n’ If you don’t want an empty line in the beginning (due to the initial /) you could do pwd | cut -b2- | tr “https://stackoverflow.com/” ‘\n’ Example: #aioobe@r60:~/tmp/files$ pwd /home/aioobe/tmp/files #aioobe@r60:~/tmp/files$ pwd | cut -b2- | tr “https://stackoverflow.com/” ‘\n’ home aioobe tmp files

techhipbettruvabetnorabahisbahis forumueduseduseduseduseduseduseduseduseduedus