I usually do this way when I am programming my script to do same what you are asking but programmatically.
echo "Hello you!" >> myfile.txt
echo "this is 2nd line text" >> file.txt
echo "last line!" >> file.txt
Voila! You got it. Important to note >>
means adding new line to existing file meanwhile >
just simply overwrite everything.
Consider this script (saved as /home/muru/test.sh
):
#! /bin/bash
DRI_PRIME=1 glxgears -info
A basic launcher for this would look like (say, save it as /home/muru/test.desktop
):
[Desktop Entry]
Type=Application
Terminal=true
Name=glx-gears-info
Exec=/home/muru/test.sh
Make them both executable:
chmod +x test.sh test.desktop
Now you should have these two entries in your home folder:
![enter image description here](https://i.stack.imgur.com/04Heh.png)
Notice how the name is glx-gears-info
even though the launcher's filename is test.desktop
. You can double click on it to start the script:
![enter image description here](https://i.stack.imgur.com/F25Y7.png)
For a script like (say, located at /home/muru/start-aria.sh
):
#!/bin/bash
touch /home/cip/Downloads/aria2/session.txt && \
aria2c --enable-rpc --rpc-listen-all \
--save-session=/home/cip/Downloads/aria2/session.txt \
--input-file=/home/cip/Downloads/aria2/session.txt -x16 -s16 -k1M \
--dir=/home/cip/Downloads/aria2
(I split the command into multiple lines for readability) the launcher file would look like (say /home/muru/start-aria.desktop
):
[Desktop Entry]
Type=Application
Terminal=false
Name=Start Aria2
Exec=/home/muru/start-aria.sh
You can set Terminal=false
here as this command probably doesn't need a terminal.
To get the terminal window when using Xfce launchers, tick 'Run in Terminal'.
![enter image description here](https://i.stack.imgur.com/INTSP.png)
A second command, that would close aria2, can be added in the same Xfce launcher: pkill aria2c
Also:
![enter image description here](https://i.stack.imgur.com/a1qpq.png)
(namely 'show last used item' and 'inside button'),
- and adding two specific icons,
the launcher will always display the current status of aria2: running or closed.
![enter image description here](https://i.stack.imgur.com/j8CeZ.png)
Best Answer
find
andsed
are your weapons of choice:That will stick
50
followed by a new line on the beginning of the file.Alternatively if you don't need recursion or complex selectors for
find
you can dropfind
completely: