for example : "a dotted filename"
ive tried to come up with bunch of codes:
Code: Select all
dottedfilename=$1
${dottedfilename##*.*/' '/} | clipit
Code: Select all
sed -e 's/./ /g'` a.dotted.filename
Code: Select all
dottedfilename=$1
${dottedfilename##*.*/' '/} | clipit
Code: Select all
sed -e 's/./ /g'` a.dotted.filename
im trying to upload files to a sites and i need to state the full name of a file that is generalygolinux wrote:Agreed. Who would want spaces in a file name in real life?
Windows users of course.golinux wrote:Agreed. Who would want spaces in a file name in real life?
Code: Select all
man mv
Code: Select all
mv a.dotted.filename undotted
Code: Select all
cat > name with spaces
cat: with: No such file or directory
cat: spaces: No such file or directory
$
Code: Select all
$ cat > name-like-this
Code: Select all
$ mv a.dotted.filename a dotted filename
usage: mv [-fi] source target
mv [-fi] source ... directory
$ cp a.dotted.filename a dotted filename
usage: cp [-fip] [-R [-H | -L | -P]] source target
cp [-fip] [-R [-H | -L | -P]] source ... directory
$ cat > a.dotted.filename
this is it
Code: Select all
$ mv a.dotted.filename a dotted file name
usage: mv [-fi] source target
mv [-fi] source ... directory
$ mv a.dotted.filename undotted
Code: Select all
touch name like this
And you call what you said a "good answer",... ?Before you derail a topic, with your attacks and flames, think about what you say, and apply it to yourself, if you can't give a good answer, then don't reply.@GarryR: for what I feel sure is the last time I will say it, if you can't give a good answer, would you please, for the love of whatever you hold Sacred, stop giving bad ones
They should then also be able to submit it to "clip it" , with the new name.by GarryRicketson » 2017-08-15 12:35 The OP can change the file name to a file name with spaces, using a file manager,
just click the "rename", rename it with spaces.
Not exactly, what I mean is what I said, most unix and linux systems, do not see a file name or dir name, with spaces, for example, if you do rename a file, using your file manage, make a name with spaces, IE : " with spaces ", then try to view / or openPost by Agvaniot » 2017-08-15 13:23
your effort to explain this is very appreciated GarryRickeston.
in other words clipit cant handle a "spaced" filename.
Code: Select all
less with spaces
Interesting, as I showed above, it does not work for me,...pylkko wrote:Garry, I just opened a terminal window on my desktop and created a file (using touch) named "name with spaces". Then edited content into it and the did the cat that you say is impossible. Well, it is not impossible.
@ dasein, If you can't or don't want to give a answer, then don't replydasein wrote:Homework
Certainly not for the reason you seem to imply. The utterly innocuous ls -l / is "blocked" for exactly the same "reason"ruffwoof wrote:creating a filename of ;rm -rf / is blocked for obvious reasons.
I will note once again that the initial problem looks like homework. There are exactly two characters that absolutely, positively cannot be used in a *nix filename. Determining which characters these are is left as an exercise for the curious.How ever if they do that, and want to open the file from the command line
they won't be able to.
You can not have file names with spaces on a linux system...
It would also create files "like " and "this". Try:GarryRicketson wrote:Hmm I just now, tried,And it created a file named "name", ???Code: Select all
touch name like this
Code: Select all
touch "name like this"
GarryRicketson wrote:Not exactly, what I mean is what I said, most unix and linux systems, do not see a file name or dir name, with spaces, for example, if you do rename a file, using your file manage, make a name with spaces, IE : " with spaces ", then try to view / or open
the file using the cli, Example :Code: Select all
less with spaces
Code: Select all
less "with spaces"
pylkko wrote:Garry, I just opened a terminal window on my desktop and created a file (using touch) named "name with spaces". Then edited content into it and the did the cat that you say is impossible. Well, it is not impossible.
You can use quotes and escape:Interesting, as I showed above, it does not work for me,...
But in any event, agreed that does not mean it is 100% impossible, there may be some
way to configure the system so it does read file names that have spaces,...
Code: Select all
cat with\ spaces
Please don't post that something can't be done when really it's just that you don't know how.If I did know a way to do this, I certainly would just share it with the OP and others,
instead of starting a flame war,... or just saying :@ dasein, If you can't or don't want to give a answer, then don't replydasein wrote:Homework
Code: Select all
"
Code: Select all
$ cat >this.file.txt
This is it
$
Code: Select all
$ mv this.file.txt "this file txt"
$ cat "this file txt"
This is it
$
Code: Select all
mv a.dotted.filename "a dotted filename"
Well I really did not think it can be done, but when I saw what pylkko and ruffwoof said,by sunrat »
Please don't post that something can't be done when really it's just that you don't know how.
For the sed part:Agvaniot wrote:im trying to take a dotted filiename "a.dotted.filename" and replace the "." with space
for example : "a dotted filename"
ive tried to come up with bunch of codes:Code: Select all
dottedfilename=$1 ${dottedfilename##*.*/' '/} | clipit
Code: Select all
sed -e 's/./ /g'` a.dotted.filename
AdrianTM wrote:There's no hacker in my grandma...
1 thread, 3 posts, 3 incorrect assumptions, 3 insults ... zero positive contribution.dasein wrote:Speaking of people who have a long history of giving bad answers...Certainly not for the reason you seem to imply. The utterly innocuous ls -l / is "blocked" for exactly the same "reason"ruffwoof wrote:creating a filename of ;rm -rf / is blocked for obvious reasons.
I'll say it again, people who don't know what they are talking about should refrain from giving bad answers. It's profoundly unclear to me how such a notion could be perceived as in any way controversial. And it's mind-boggling to see anyone, much less a staff member, defend the practice.
This isn't funny. Really. No one comes here to be misinformed or misled. And folks who repeatedly give technically inaccurate answers out of ignorance are no better than (actually no different from) folks who would give bad answers just for lulz.
It's truly sad and pathetic that FDN's devotion to "free speech" supersedes their devotion to technical accuracy. It's an egregious and corrosive philosophy.
For instance, there is not a single accurate statement in this quote from GarryRI will note once again that the initial problem looks like homework. There are exactly two characters that absolutely, positively cannot be used in a *nix filename. Determining which characters these are is left as an exercise for the curious.How ever if they do that, and want to open the file from the command line
they won't be able to.
You can not have file names with spaces on a linux system...
From the Gnome desktop:Agvaniot wrote:im trying to take a dotted filiename "a.dotted.filename" and replace the "." with space
for example : "a dotted filename"
[...]
Code: Select all
touch 'a dotted filename'
That will modify a file. However, in most computer science classes they want an answer that is generic, so that you could use it to change 1000 files all in different folders or something to that extent. You will need a small perl script to do it efficiently, and that is what the code in the OP is trying to do, only struggling with the escaping special chars.RU55EL wrote: From the Gnome desktop:
Simple: select the file name, hit F2 to rename the file, hit the right arrow key to move to the end of the file name, while holding the control key hit the backspace key (that should place the cursor between the "f" and the "." in "a.dotted.filename, stop pressing the control key and hit backspace once, then hit the space bar once. You have now changed one of the dots to a space. Simply repeat this for the other dot, and you are done. Hit enter to complete the file name change.
]
There's one method.dilberts_left_nut wrote:For the sed part:
A . is a wildcard that matches any character, you need to escape it with a \ to match an actual .
There's another.RU55EL wrote:Single quotes also work for creating a file name with spaces in Debian:Code: Select all
touch 'a dotted filename'