10
votes
Accepted
Remove spaces from the 3rd line onwards in a file on linux
Using sed:
sed '1,2!s/ //g' InputFile.txt
Explanation:
1,2! for all lines except lines 1 and 2
s/ //g removes all spaces (globally) in the non-excluded lines (from the third line onwards).
Results ...
7
votes
Remove spaces from the 3rd line onwards in a file on linux
Using any awk:
$ awk 'NR>2{gsub(/ /,"")} 1' file
This is the first line
This is the second line
Thisisthethirdline
Thisisthefourthline
Thisisthefifthline
Thisisthesixthline
....
....
....
6
votes
Accepted
Keyboard shortcuts for running last command with changes?
In bash, you can use quick substitution with ^...^...:
^string1^string2^
Quick Substitution. Repeat the last command, replacing string1 with
string2. Equivalent to !!:s^string1^string2^.
The ...
4
votes
Remove spaces from the 3rd line onwards in a file on linux
You asked for a sed or awk solution, and for such a simple task I'd probably stick to one of those; nevertheless this could be be done using Perl as well:
perl -pe '$. > 2 && s/ //g' file
-...
3
votes
Keyboard shortcuts for running last command with changes?
Muru's method is definetly simpler, and has the advantage of not forcing the user to give up on Emacs-style keybindings.
However for those used to Vi motions, with Bash set in Vi mode (set -o vi), to ...
1
vote
After double-clicking a script on the desktop, show output in a terminal
A .desktop file is a common way to go about this.
[Desktop Entry]
Exec=/home/<YOUR_USER>/local/bin/<SCRIPT>.sh
Name=The naaaaame
Terminal=true
Type=Application
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
command-line × 23104bash × 5454
scripts × 2756
gnome-terminal × 879
text-processing × 872
permissions × 717
server × 697
apt × 676
ssh × 565
14.04 × 542
sudo × 514
software-installation × 498
files × 490
python × 486
16.04 × 448
gnome × 446
networking × 431
directory × 422
grep × 367
18.04 × 361
shortcut-keys × 358
sed × 354
12.04 × 352
package-management × 335
find × 331