Trouble with appending a long string to a file

Clash 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"?
shell-script scripting top
add a comment |Â
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"?
shell-script scripting top
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
add a comment |Â
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"?
shell-script scripting top
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
shell-script scripting top
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
add a comment |Â
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
add a comment |Â
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
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
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
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
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
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
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