Display result of a command right aligned in terminal
I have a script that goes through many different checks and I use the success, failure functions defined in /etc/init.d/functions to clearly show the action result on the terminal.
That works great, except in some cases where I print a bit more text, I then get the result box displayed over my text:
/usr/share/app/lib/lib_mylib.so lib[ OK ]o matches as expected
Where I'd like it to be displayed:
/usr/share/app/lib/lib_mylib.so lib_mylib.so matches as expected [ OK ]
Looking around I saw that /etc/init.d/functions is using a variable RES_COL to position where to print the result field. If /etc/sysconfig/init exists then RES_COL is taken from there, set by default to 60 chars.
I've tried export RES_COL=100 after sourcing /etc/init.d/functions to no avail.
Furthermore I'd like the result field to be right-aligned with the terminal window and not having to hard-code any value for that. Any idea?
bash shell terminal
bumped to the homepage by Community♦ 5 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
add a comment |
I have a script that goes through many different checks and I use the success, failure functions defined in /etc/init.d/functions to clearly show the action result on the terminal.
That works great, except in some cases where I print a bit more text, I then get the result box displayed over my text:
/usr/share/app/lib/lib_mylib.so lib[ OK ]o matches as expected
Where I'd like it to be displayed:
/usr/share/app/lib/lib_mylib.so lib_mylib.so matches as expected [ OK ]
Looking around I saw that /etc/init.d/functions is using a variable RES_COL to position where to print the result field. If /etc/sysconfig/init exists then RES_COL is taken from there, set by default to 60 chars.
I've tried export RES_COL=100 after sourcing /etc/init.d/functions to no avail.
Furthermore I'd like the result field to be right-aligned with the terminal window and not having to hard-code any value for that. Any idea?
bash shell terminal
bumped to the homepage by Community♦ 5 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
add a comment |
I have a script that goes through many different checks and I use the success, failure functions defined in /etc/init.d/functions to clearly show the action result on the terminal.
That works great, except in some cases where I print a bit more text, I then get the result box displayed over my text:
/usr/share/app/lib/lib_mylib.so lib[ OK ]o matches as expected
Where I'd like it to be displayed:
/usr/share/app/lib/lib_mylib.so lib_mylib.so matches as expected [ OK ]
Looking around I saw that /etc/init.d/functions is using a variable RES_COL to position where to print the result field. If /etc/sysconfig/init exists then RES_COL is taken from there, set by default to 60 chars.
I've tried export RES_COL=100 after sourcing /etc/init.d/functions to no avail.
Furthermore I'd like the result field to be right-aligned with the terminal window and not having to hard-code any value for that. Any idea?
bash shell terminal
I have a script that goes through many different checks and I use the success, failure functions defined in /etc/init.d/functions to clearly show the action result on the terminal.
That works great, except in some cases where I print a bit more text, I then get the result box displayed over my text:
/usr/share/app/lib/lib_mylib.so lib[ OK ]o matches as expected
Where I'd like it to be displayed:
/usr/share/app/lib/lib_mylib.so lib_mylib.so matches as expected [ OK ]
Looking around I saw that /etc/init.d/functions is using a variable RES_COL to position where to print the result field. If /etc/sysconfig/init exists then RES_COL is taken from there, set by default to 60 chars.
I've tried export RES_COL=100 after sourcing /etc/init.d/functions to no avail.
Furthermore I'd like the result field to be right-aligned with the terminal window and not having to hard-code any value for that. Any idea?
bash shell terminal
bash shell terminal
edited Feb 9 '15 at 18:06
Gilles
530k12810621589
530k12810621589
asked Feb 9 '15 at 13:55
fdufffduff
2,64731934
2,64731934
bumped to the homepage by Community♦ 5 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
bumped to the homepage by Community♦ 5 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
The tput command can be used to control the cursor, assuming you have your TERM variable set correctly. In combination with the LINES and COLUMNS variables, you can position the cursor wherever you want.
The syntax is:
tput cup line column
For example:
tput cup $((LINES-2)) $((COLUMNS-4));echo "[OK]"
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "106"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f183821%2fdisplay-result-of-a-command-right-aligned-in-terminal%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
The tput command can be used to control the cursor, assuming you have your TERM variable set correctly. In combination with the LINES and COLUMNS variables, you can position the cursor wherever you want.
The syntax is:
tput cup line column
For example:
tput cup $((LINES-2)) $((COLUMNS-4));echo "[OK]"
add a comment |
The tput command can be used to control the cursor, assuming you have your TERM variable set correctly. In combination with the LINES and COLUMNS variables, you can position the cursor wherever you want.
The syntax is:
tput cup line column
For example:
tput cup $((LINES-2)) $((COLUMNS-4));echo "[OK]"
add a comment |
The tput command can be used to control the cursor, assuming you have your TERM variable set correctly. In combination with the LINES and COLUMNS variables, you can position the cursor wherever you want.
The syntax is:
tput cup line column
For example:
tput cup $((LINES-2)) $((COLUMNS-4));echo "[OK]"
The tput command can be used to control the cursor, assuming you have your TERM variable set correctly. In combination with the LINES and COLUMNS variables, you can position the cursor wherever you want.
The syntax is:
tput cup line column
For example:
tput cup $((LINES-2)) $((COLUMNS-4));echo "[OK]"
answered Feb 9 '15 at 14:51
rghomerghome
33916
33916
add a comment |
add a comment |
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f183821%2fdisplay-result-of-a-command-right-aligned-in-terminal%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown