Trouble with appending a long string to a file

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
0
down vote

favorite












I'm trying to learn bash scripting and I would like to write a script that outputs the top processes every two seconds, such as



while [ 1 ]; do
# echo "$(top -b -o +%MEM | head -n 15)" # for testing
echo "$(top -b -o +%MEM | head -n 15)" >> /test_unix.txt
echo "***********************************************" >> /test_unix.txt
printf "n" >> /test_unix.txt
sleep 2
done


When I run this script normally I get (among others) the following output:



PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
5299 root 20 0 6436592 5.164g 19352 S 106.2 33.0 2:45.67 /very/long/path/to/bin/node --expose-gc --max_old_space_size=8000 /another/very/long/path/node_m+


So we see that the string ends with a plus (+) sign (i.e., path/node_m+) instead of displaying the full command. The strange thing is when I zoom out (enough) on my Ubuntu terminal (Ctrl+-), and then run the script, it will append the full string as such



PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
5299 root 20 0 6436592 5.164g 19352 S 106.2 33.0 2:45.67 /very/long/path/to/bin/node --expose-gc --max_old_space_size=8000 /another/very/long/path/node_modules/more/path/index.js /path/.nvm/versions/node/


How can I ensure that the script will always output the full string, even when the terminal is not "zoomed out"?










share|improve this question























  • Maybe helpful: unix.stackexchange.com/questions/95877/…
    – Jeff Schaller
    4 mins ago










  • Possible duplicate of Why does `nohup top` cut the output lines?
    – Jeff Schaller
    2 mins ago














up vote
0
down vote

favorite












I'm trying to learn bash scripting and I would like to write a script that outputs the top processes every two seconds, such as



while [ 1 ]; do
# echo "$(top -b -o +%MEM | head -n 15)" # for testing
echo "$(top -b -o +%MEM | head -n 15)" >> /test_unix.txt
echo "***********************************************" >> /test_unix.txt
printf "n" >> /test_unix.txt
sleep 2
done


When I run this script normally I get (among others) the following output:



PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
5299 root 20 0 6436592 5.164g 19352 S 106.2 33.0 2:45.67 /very/long/path/to/bin/node --expose-gc --max_old_space_size=8000 /another/very/long/path/node_m+


So we see that the string ends with a plus (+) sign (i.e., path/node_m+) instead of displaying the full command. The strange thing is when I zoom out (enough) on my Ubuntu terminal (Ctrl+-), and then run the script, it will append the full string as such



PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
5299 root 20 0 6436592 5.164g 19352 S 106.2 33.0 2:45.67 /very/long/path/to/bin/node --expose-gc --max_old_space_size=8000 /another/very/long/path/node_modules/more/path/index.js /path/.nvm/versions/node/


How can I ensure that the script will always output the full string, even when the terminal is not "zoomed out"?










share|improve this question























  • Maybe helpful: unix.stackexchange.com/questions/95877/…
    – Jeff Schaller
    4 mins ago










  • Possible duplicate of Why does `nohup top` cut the output lines?
    – Jeff Schaller
    2 mins ago












up vote
0
down vote

favorite









up vote
0
down vote

favorite











I'm trying to learn bash scripting and I would like to write a script that outputs the top processes every two seconds, such as



while [ 1 ]; do
# echo "$(top -b -o +%MEM | head -n 15)" # for testing
echo "$(top -b -o +%MEM | head -n 15)" >> /test_unix.txt
echo "***********************************************" >> /test_unix.txt
printf "n" >> /test_unix.txt
sleep 2
done


When I run this script normally I get (among others) the following output:



PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
5299 root 20 0 6436592 5.164g 19352 S 106.2 33.0 2:45.67 /very/long/path/to/bin/node --expose-gc --max_old_space_size=8000 /another/very/long/path/node_m+


So we see that the string ends with a plus (+) sign (i.e., path/node_m+) instead of displaying the full command. The strange thing is when I zoom out (enough) on my Ubuntu terminal (Ctrl+-), and then run the script, it will append the full string as such



PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
5299 root 20 0 6436592 5.164g 19352 S 106.2 33.0 2:45.67 /very/long/path/to/bin/node --expose-gc --max_old_space_size=8000 /another/very/long/path/node_modules/more/path/index.js /path/.nvm/versions/node/


How can I ensure that the script will always output the full string, even when the terminal is not "zoomed out"?










share|improve this question















I'm trying to learn bash scripting and I would like to write a script that outputs the top processes every two seconds, such as



while [ 1 ]; do
# echo "$(top -b -o +%MEM | head -n 15)" # for testing
echo "$(top -b -o +%MEM | head -n 15)" >> /test_unix.txt
echo "***********************************************" >> /test_unix.txt
printf "n" >> /test_unix.txt
sleep 2
done


When I run this script normally I get (among others) the following output:



PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
5299 root 20 0 6436592 5.164g 19352 S 106.2 33.0 2:45.67 /very/long/path/to/bin/node --expose-gc --max_old_space_size=8000 /another/very/long/path/node_m+


So we see that the string ends with a plus (+) sign (i.e., path/node_m+) instead of displaying the full command. The strange thing is when I zoom out (enough) on my Ubuntu terminal (Ctrl+-), and then run the script, it will append the full string as such



PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
5299 root 20 0 6436592 5.164g 19352 S 106.2 33.0 2:45.67 /very/long/path/to/bin/node --expose-gc --max_old_space_size=8000 /another/very/long/path/node_modules/more/path/index.js /path/.nvm/versions/node/


How can I ensure that the script will always output the full string, even when the terminal is not "zoomed out"?







shell-script scripting top






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 12 mins ago

























asked 15 mins ago









Hunter

1285




1285











  • Maybe helpful: unix.stackexchange.com/questions/95877/…
    – Jeff Schaller
    4 mins ago










  • Possible duplicate of Why does `nohup top` cut the output lines?
    – Jeff Schaller
    2 mins ago
















  • Maybe helpful: unix.stackexchange.com/questions/95877/…
    – Jeff Schaller
    4 mins ago










  • Possible duplicate of Why does `nohup top` cut the output lines?
    – Jeff Schaller
    2 mins ago















Maybe helpful: unix.stackexchange.com/questions/95877/…
– Jeff Schaller
4 mins ago




Maybe helpful: unix.stackexchange.com/questions/95877/…
– Jeff Schaller
4 mins ago












Possible duplicate of Why does `nohup top` cut the output lines?
– Jeff Schaller
2 mins ago




Possible duplicate of Why does `nohup top` cut the output lines?
– Jeff Schaller
2 mins ago















active

oldest

votes











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',
convertImagesToLinks: false,
noModals: false,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













 

draft saved


draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f477590%2ftrouble-with-appending-a-long-string-to-a-file%23new-answer', 'question_page');

);

Post as a guest



































active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes















 

draft saved


draft discarded















































 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f477590%2ftrouble-with-appending-a-long-string-to-a-file%23new-answer', 'question_page');

);

Post as a guest













































































Popular posts from this blog

Peggy Mitchell

The Forum (Inglewood, California)

Palaiologos