commands to use or script
how do i copy a file that has no end and add .txt to it
|
The 'end' is called an (file) extension.
Please, google some tutorials on the 'cp' command. |
@ Reply
Not sure what you mean by no end to it.
cp is the command which is use to copy a file. You can use the same command to copy the file with the different name. Suppose you have a file with the name test under /home/user/test and you want to move it to /home/user/testing folder as test.txt then you can run the following command. Code:
cp /home/user/test /home/user/testing/test.txt Code:
man cp |
T3RM1NVT0R thanks alot atleast it helps i need a script that i will be able to run and which will copy files without an externsion like
cp /home/user/test and add .txt /home/user/testing/test.txt iis there any command i can use in the script????? |
can i write
best=file cp $best $best.txt?? |
@ Reply
Nope. That is not the correct way of writing the script.
How many files are there which you want to change the extensions for? If it is just for one file then script is not required. If there are many then yes you do need a script. If you already have a script then we guys can help you fix the problem in the script. If you do not have a script or you do not know how to create a script then you should better have a look at the following tutorials: http://www.freeos.com/guides/lsst/ /* For beginners */ http://linuxconfig.org/Bash_scripting_Tutorial http://tldp.org/LDP/abs/html/ /* This one is for advanced user */ I hope this helps |
im copying alot of files this is a script im trying to modify but not sure how to make it copy files without an extension and then add a .txt to them
abc= #assuming the file does not have an end or extension foo='abc$' FROM=/user/share/doc TO=~/home/doc for grep $foo in $from do echo the files have no file extension cp -r $FROM $TO |
That code doesn't make any sense to me. Are the paths in TO or FROM directories or files? It seems they should be directories, but then why are you using grep (in a place where it's not valid syntax)? And then why are you discarding the results of the grep and simply copying TO to FROM?
|
:twocents:
First of all, renaming files is one of the most requested scripting questions here and on the net. A quick search or two of the archives will turn up dozens of previous threads with all the information you need. Second, there are also already a number of ready-made renaming tools available that can do exactly what you want. A search of your distribution's software repositories should tell you what's available. Third, please use [code][/code] tags around your code, to preserve formatting and to improve readability. Fourth, when you have a problem, it helps to define it clearly at the outset. You could give us some actual examples of the filenames and how you want to rename them, as well as any pertinent details about the environment and the tools you have available. Check out the first link in my signature, and follow on from there to Eric S. Raymond's guide on how to ask questions the smart way. Properly framing your posts will help you to get the responses you need, without wasting people's time, either ours or yours. |
Examples
Code:
# renames (moves) the file |
All times are GMT -5. The time now is 10:47 PM. |