The Stack Overflow podcast is back! Listen to an interview with our new CEO.

New answers tagged

0

You can use the printf() command under bash to "columnar format" your output. The %-20s means left-justify + pad the column 20 spaces, while %20s means right-justify. First="Milton" Last="Waddams" Age="38" $ printf "%-20s%-30s%-40s" ${First} ${Last} ${Age} Milton Waddams 38 There is probably a more efficient way to ...


0

To join lines two by two with a tab (which Excel should understand as a column separator) you can pipe the file through: sed -n '1~2h;2~2{H;x;s/\n/\t/;p}'


0

The output is separated by space. Probably. It depends on how you created the text file and [exactly] what you wrote into it. To find out, use the od utility (I'm assuming your use of the term "shell script" implies some flavour of Unix): $ cat f1 A B C D $ od -cx f1 0000000 A B C D \n 4120 4220 4320 440a ...


2

Excel can import delimiter separated files ("CSV"). If the space character is exclusively used as a delimiter in the file, you can easily replace all instances of the space character in the file with something Excel is more likely to recognize, like comma, semicolon, or tab characters. The sed command can be used for this purpose. Example: $ cat ~/test....


0

You currently have no loops, not even of any kind. Your script runs, waits for you at the choose command, and then drops out at the end. The illusion of a loop is created by the recursive call to asadmin again, which also waits for you at the choose command and then, itself, drops out at the end. My first suggestion would be to add an "exit" option into ...


5

No, a basic Bourne/POSIX shell (/bin/sh) cannot be expected to include any built-in facilities for TCP connections. See comparision of command shells in Wikipedia. The bash shell would have TCP and UDP client capabilities with a special handling of certain filenames: for example, using /dev/tcp/<hostname>/<port> in input/output redirection on a ...


2

in Bash, execution of code after each command can be achieved using the "trap" builtin and the "DEBUG" level. in bash do: help trap or refer to bash manual page, and look for the trap section example: trap 'date' DEBUG This will execute the command "date" juste after each command. Of course you can format the timestamp as you want, refer to the "date" ...


Top 50 recent answers are included