LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 06-14-2011, 01:17 PM   #1
cristi92b
Member
 
Registered: May 2011
Posts: 94

Rep: Reputation: Disabled
is there a command for cut and paste?


Is there a terminal command that allows you to cut the text in a text file and paste it into antother text file?
 
Old 06-14-2011, 01:25 PM   #2
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
Hi,

Not that I know of.

If you have your mouse set up to work in the terminal you can use that.
 
Old 06-14-2011, 03:11 PM   #3
cristi92b
Member
 
Registered: May 2011
Posts: 94

Original Poster
Rep: Reputation: Disabled
I know I can copy the text with "cat" command, but is there a way of clearing a text file without deleting it and create a new file? another command... or maybe a flag for "cat"?
 
Old 06-14-2011, 03:14 PM   #4
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Germany
Distribution: Whatever fits the task best
Posts: 17,148
Blog Entries: 2

Rep: Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886
To delete the content of a file without deleting/re-creating it you can just do this:
Code:
> yourfile
 
Old 06-14-2011, 03:16 PM   #5
repo
LQ 5k Club
 
Registered: May 2001
Location: Belgium
Distribution: Arch
Posts: 8,529

Rep: Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899
You can use
Code:
cat /dev/null > file
Kind regards
 
1 members found this post helpful.
Old 06-14-2011, 03:16 PM   #6
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
Hi,

If you want to delete the complete content of a file:
Code:
> filename
Replacing the complete content is also possible:
Code:
echo "erased" > filename
If you use >> instead of > in the second example, the text is appended to the file (at the bottom).

Hope this helps.
 
Old 06-14-2011, 03:17 PM   #7
kindofabuzz
Member
 
Registered: Mar 2010
Location: There
Distribution: Linux Mint 17.1
Posts: 237

Rep: Reputation: 46
I know for sure there is a cut command. It may not be what you want. Do a man cut and see if it fits your needs. There is a paste command too.
 
Old 06-14-2011, 03:36 PM   #8
lithos
Senior Member
 
Registered: Jan 2010
Location: SI : 45.9531, 15.4894
Distribution: CentOS, OpenNA/Trustix, testing desktop openSuse 12.1 /Cinnamon/KDE4.8
Posts: 1,144

Rep: Reputation: 217Reputation: 217Reputation: 217
Hi,

I don't know how to do it specifically like you want, but SED might be the start for it.
examples:
1. sed
2. linuxjournal/7231
 
Old 06-14-2011, 03:57 PM   #9
cristi92b
Member
 
Registered: May 2011
Posts: 94

Original Poster
Rep: Reputation: Disabled
Thank you very much!!!
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Cut and paste from command line dulli1 Linux - Newbie 9 10-12-2010 09:31 PM
xterminals - cut and paste. Black Hawk Linux - Newbie 1 12-08-2006 02:36 PM
Icons for cut, paste, etc. kyutums Linux - General 1 07-21-2004 12:38 PM
How do you cut and paste from aterm? patpawlowski Linux - Software 3 02-20-2004 10:16 PM
cut and paste c0c0deuz Linux - Newbie 6 11-01-2001 12:38 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 09:34 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration