I am created file use "cat > sample.txt". after i used "cat -b sample.txt". how to save it. ctrl+x or F2 is not working.cat -b command
Asked
Active
Viewed 52 times
0
-
What do you mean "save it"? Do you want the line numbers to go into the actual file? If yes, why? – glenn jackman Mar 24 '20 at 15:41
-
yes. i want to know to my knowledge. – TipVisor Mar 24 '20 at 16:30
-
Beware that `cat -b sample.txt > sample.txt` will not work. In fact it will destroy the file. That's because bash will process the redirection **first** (truncating the file to zero bytes) before launching the cat command. – glenn jackman Mar 24 '20 at 16:37
-
You can `cat -b sample.txt > tempfile && mv tempfile sample.txt` – glenn jackman Mar 24 '20 at 16:38
-
Or install the `moreutils` package and `cat -b sample.txt | sponge sample.txt` – glenn jackman Mar 24 '20 at 16:42
-
This command is working correctly. Thank you. cat -b sample.txt > tempfile && mv tempfile sample.txt – TipVisor Mar 25 '20 at 03:15