Skip to main content
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 ...
karel's user avatar
  • 118k
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 .... .... ....
Ed Morton's user avatar
  • 364
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 ...
muru's user avatar
  • 202k
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 -...
kos's user avatar
  • 38.5k
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 ...
kos's user avatar
  • 38.5k
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
progonkpa's user avatar
  • 111

Only top scored, non community-wiki answers of a minimum length are eligible