I tried renaming a file in Ubuntu



  • ubuntu@ip-xx-xxx-xx-xxx:/var/www$ rename index.php info.php
    Not enough arguments for index at (eval 1) line 1, near "index."
    Bareword "php" not allowed while "strict subs" in use at (eval 1) line 1.

    What the FUCK does that MEAN!?!?! I understand every word up to "arguments", beyond that point it's gibberish.

    Which brings up two questions:

    1) What's the command for renaming a file?

    Apparently there isn't one, but you can change the file name using the "mv" (presumably "move?") command.

    2) What in holy shit does "rename" do if not rename files?

    Fuck if I know.



  • Ubuntu's handy-dandy documentation discusses how to use the terminal. The last example it gives?

    How to create upsidedown and/or reverse text with your terminal

    THAT IS SOOOOO USEFUL! (Of course the actual program that does the operation is in Perl and has nothing to do with your terminal, but I'll forgive that since it's SO USEFUL!!!)

    I hate my job.



  • Doesn't the "." in "index.php" automatically expand to the current directory before parsing?

    So, the command you're sending is "rename index/var/www$/php info/var/www$/php"

    Try using quotes around the filenames



  • I've always just used "mv" to rename files. No idea what the actual "rename" command does.


  • Considered Harmful

    @blakeyrat said:

    Apparently there isn't one,

    Sure there is, it's just called...

    @blakeyrat said:
    you can change the file name using the "mv" (presumably "move?") command.

    ...but you just said...

    Your complaint is you don't like the name of the command? Just shove alias ren="mv -T" in .bashrc.



  • @joe.edwards said:

    Your complaint is you don't like the name of the command? Just shove alias ren="mv -T" in .bashrc.

    Renaming a file and moving a file aren't the same operation. So you end up with strange-ass system where "move" can result in a different file name (WTF!??!) and "rename" can result in the file ending up in a different directory (WTF!?!?!). Plus the mnemonic (or "gnemonic" according to Ubuntu) is totally worthless for renaming a file. Why would anybody think of "move"? (Much less "mv"?)

    Who designed this mess? Why would you conflate two wholly unrelated commands into one? What the FUCK were they thinking?


  • Considered Harmful

    @blakeyrat said:

    "rename" can result in the file ending up in a different directory (WTF!?!?!)

    I put the -T in the alias above to prevent that. I haven't tested its efficacy though.
    @blakeyrat said:
    Who designed this mess? Why would you conflate two wholly unrelated commands into one? What the FUCK were they thinking?

    You can't blame Ubuntu or Linux for this one: it's old-as-dirt, from its Unix origins.


  • ♿ (Parody)

    "rename" is actually a perl script. We know you're a retard, but some day we still hope that you might figure out how to get help while in the terminal. For instance, typing the command by itself often gets you a quick "Usage: command ...options..." sort of display. And of course, there's always "man rename". But I suppose an auto-beclowning rant is more fun.

    Also, if you're using a windowed application, and you click on the "Help" thing at the top, it generally won't bring up the help right away. Usually, this displays a menu, and then you can select something more detailed. HTH



  • @blakeyrat said:

    @joe.edwards said:
    Your complaint is you don't like the name of the command? Just shove alias ren="mv -T" in .bashrc.

    Renaming a file and moving a file aren't the same operation. So you end up with strange-ass system where "move" can result in a different file name (WTF!??!) and "rename" can result in the file ending up in a different directory (WTF!?!?!). Plus the mnemonic (or "gnemonic" according to Ubuntu) is totally worthless for renaming a file. Why would anybody think of "move"? (Much less "mv"?)

    Who designed this mess? Why would you conflate two wholly unrelated commands into one? What the FUCK were they thinking?

     

    If its on the same filesystem, then on UNIX/POSIX-based systems move and rename are the same operation as you're only giving a new name (well... updating a directory entry (or "link")) to the [url=http://en.wikipedia.org/wiki/Inode]inode[/url] the represents the file.

    Seriously, haven't you ever taken an Operating Systems class of some sort?

     


  • Considered Harmful

    @powerlord said:

    If its on the same filesystem, then on UNIX/POSIX-based systems it's the same operation as you're only giving a new name to the inode the represents the file.

    Great, now we're going to get another lecture about exposing implementation details to the user.



  •  Again the WTF is of type PEBKAC, because you are to sexy to read documentation for commands, you do not know, what they do ...


    RENAME(1)                                            User Commands                                            RENAME(1)
    

    NAME
    rename - rename files

    SYNOPSIS
    rename [options] expression replacement file...

    DESCRIPTION
    rename will rename the specified files by replacing the first occurrence of expression in their name by replace‐
    ment.

    OPTIONS
    -v, --verbose
    Give visual feedback which files where renamed, if any.

       -V, --version
              Display version information and exit.
    
       -h, --help
              Display help text and exit.
    

    EXAMPLES
    Given the files foo1, ..., foo9, foo10, ..., foo278, the commands

              rename foo foo0 foo?
              rename foo foo0 foo??
    
       will turn them into foo001, ..., foo009, foo010, ..., foo278.  And
    
              rename .htm .html *.htm
    
       will fix the extension of your html files.
    

    WARNING
    The renaming has no safeguards. If the user has permission to rewrite file names, the command will perform the
    action without any questions. For example, the result can be quite drastic when the command is run as root in
    the /lib directory. Always make a backup before running the command, unless you truly know what you are doing.

    SEE ALSO
    mmv(1), mv(1)

    AVAILABILITY
    The rename command is part of the util-linux package and is available from ftp://ftp.ker
    nel.org/pub/linux/utils/util-linux/.

    util-linux June 2011 RENAME(1)


  • Considered Harmful

    @gilhad said:

    DESCRIPTION
    rename will rename the specified files by replacing the first occurrence of expression in their name by replace‐
    ment.

    That actually sounds really useful.


  • ♿ (Parody)

    @blakeyrat said:

    Why would you conflate two wholly unrelated commands into one? What the FUCK were they thinking?

    They were thinking that they aren't unrelated. Because they aren't. Why the FUCK aren't you thinking?



  • @powerlord said:

    Seriously, haven't you ever taken an Operating Systems class of some sort?

    Not one I recall. Why should I have to? I'm setting up a web server, not writing an operating system.

    Just because this particular bit of bullshit is old doesn't mean it's not bullshit. It is bullshit and I'm calling it out.



  • @blakeyrat said:

    @powerlord said:
    Seriously, haven't you ever taken an Operating Systems class of some sort?

    Not one I recall. Why should I have to? I'm setting up a web server, not writing an operating system.

    Just because this particular bit of bullshit is old doesn't mean it's not bullshit. It is bullshit and I'm calling it out.

    Because I was under the impression that you had a CS degree of some kind and they usually require it.  Especially for programming-related CS degrees.

     



  • @gilhad said:

    NAME
    rename - rename files

    SYNOPSIS
    rename [options] expression replacement file...

    Well, this is a manpage for the wrong command. This one is known on some systems as perl-rename. But not on Ubuntu or Debian.



  • @powerlord said:

    Because I was under the impression that you had a CS degree of some kind

    Why?

    @powerlord said:

    and they usually require it

    Who is "they"?


  • Considered Harmful

    @blakeyrat said:

    @powerlord said:
    Because I was under the impression that you had a CS degree of some kind

    Why?


    Because you have a career using computers.
    @blakeyrat said:
    @powerlord said:
    and they usually require it

    Who is "they"?


    CS degrees. It's the same sentence FFS.




    @Catch-22 said:

    'Wasn't he sweet?' said Yossarian. 'Maybe they should give him three votes.'

    'Who's they?' Dunbar demanded suspiciously.



  • Thread synopsis:
    <font face="comic sans ms">

    • I have no idea how to copy a file in linux
    • This is all linux's fault! They should make every command work how I expect to
    • You use This Command, which can also do These Other Things
    • That's stupid, every command should only do one thing
    • No, you're stupid
    • OS dick-waving fight



  • @boomzilla said:

    "rename" is actually a perl script.
    @spamcourt said:
    @gilhad said:
    NAME
    rename - rename files

    SYNOPSIS
    rename [options] expression replacement file...

    Well, this is a manpage for the wrong command. This one is known on some systems as perl-rename. But not on Ubuntu or Debian.
    So Linux, or some variations of Linux, may not have a "rename" command that's actually built into the operating system, something that DOS 1.0 had 30 years ago.  That's the most retarded thing I've ever heard.



  • Serious question:

    What is the best way to deploy a website to a Linux web server?

    I could either set the web server up as a Git client and log into it and do a git update or whatever git's name for that command is, or I could set up a SFTP server and user account and we could SFTP the files to the server... the latter seems like it better separates the development process from the deployment process, and seems to be how (almost) all Linux server providers work. (Except Heroku. Which sucks.)

    How do you keep track of application-specific configuration on Linux webservers, since they don't seem to have anything like IIS' web.config file? What if two applications have mutually-exclusive configurations?

    I keep getting assigned this bullshit by my boss and I'm completely incompetent to handle it.



  • @joe.edwards said:

    @gilhad said:

    DESCRIPTION
           rename will rename the specified files by replacing the first occurrence of expression in their name by replace‐
           ment.
    That actually sounds really useful.
    Indeed. I've rolled my own using foreach and mv countless times, because I've used *nix OSs for 30 years and never knew this utility existed. Anybody know how long it's been around?

     



  •  I do not have Debian or Ubuntu, but I think, that even on them the man command works, so it is not problem to get description of unknown command.

     

    Anyway Linux was targeted at technically skilled administrators, who are able to read manuals and learn  what they need. If rat is unwilling to learn, then he should select some system, who is targeted at computer-illiteral people - maybe MS BOB would be good for him - no confusing command prompts, no learning, just nice and friendly pictures and guide always willing jump in and suggest what to do.



  • @joe.edwards said:

    Because you have a career using computers.

    Oh. Well I don't. And I take great pleasure in giving a thumbs-down to interviewees who have CS degrees but don't know shit. Which is most of interviewees with CS degrees.

    Maybe they're better now, but back when I was in college, the CS curriculum was totally useless.

    @joe.edwards said:

    CS degrees. It's the same sentence FFS.

    Oh fair enough. I thought you meant "they" as in my employers or something, I dunno, I was confused. Normally people don't refer to abstract concepts like "CS degrees" as "they".


  • Considered Harmful

    Well, there are a number of web servers available for Linux and the answer varies between them.

    I'm going to asspull that Apache is the most common, in which case each VHost can have a separate configuration or just override the global settings as-needed.

    All that said, I understand there are configuration management tools that should be preferred in an enterprise or commercial environment to keep things consistent across multiple servers. Morbs mentioned a few of them I seem to recall, but I haven't used any of them personally; maybe someone else can fill in here.



  • @El_Heffe said:

    So Linux, or some variations of Linux, may not have a "rename" command that's actually built into the operating system, something that DOS 1.0 had 30 years ago.  That's the most retarded thing I've ever heard.

    Well, if you call a kernel paired with a custom-built init which literally does nothing but sit idly an "operating system" then sure why not.

    On the other hand, I don't know a single distribution that doesn't ship by default with at least busybox, if not coreutils or some equivalent package providing "mv". So if you have somewhat stricter standards, then no.



  • @El_Heffe said:

    So Linux, or some variations of Linux, may not have a "rename" command that's actually built into the operating system, something that DOS 1.0 had 30 years ago.  That's the most retarded thing I've ever heard.
    Sure it does; it's just not called "rename." It's called "mv", because it can not only move a file from one name to another in the same location; it can move a file to another location, even across file system boundaries, with the same or changed name.

     



  •  OS is something different, then usual service programs. I bet, that Ubuntu have something, what can do the renaming too, but it may have little different name (maybe perl-rename, as sugested).

     

    OS is what talks to HW directly and server other programs as base layer.

     

    Service programs (as mv, rename, find, sed, awk, bash, ....) servers as tools for user and other programs/scripts. You can install suite of such programs, that fits your needs. It is not OS area to do.

     

    Windows are just chunk of software, which wants do everyting at one time, from OS work via service programs, via window manager to fully user programs, as a web-browser, but which is not excelent at nothing of that and makes difficult to use computer in more advanced ways, that MS managers envisioned. 


  • ♿ (Parody)

    @HardwareGeek said:

    @El_Heffe said:
    So Linux, or some variations of Linux, may not have a "rename" command that's actually built into the operating system, something that DOS 1.0 had 30 years ago.  That's the most retarded thing I've ever heard.

    Sure it does; it's just not called "rename." It's called "mv", because it can not only move a file from one name to another in the same location; it can move a file to another location, even across file system boundaries, with the same or changed name.

    Yeah, but you absolutely have to agree that it's embarrassing that the guys who created mv didn't have enough smarts to predict what DOS 1.0 would do ten years later.


  • Considered Harmful

    @gilhad said:

    OS is what talks to HW directly and server other programs as base layer.

    You mean the kernel, which is just one component of an operating system.
    @gilhad said:
    Windows are just chunk of software, which wants do everyting at one time, from OS work via service programs, via window manager to fully user programs, as a web-browser, but which is not excelent at nothing of that and makes difficult to use computer in more advanced ways, that MS managers envisioned. 

    I don't know what you're going on about any more.



  • @joe.edwards said:

    Well, there are a number of web servers available for Linux and the answer varies between them.

    Yeah sorry, I should have specified: I put on Apache2 because it seems like the path of least resistance. Although the web dev working on this does actually use Nginx, just looking at Nginx's installation instructions for Ubuntu* was enough for me to say "no thanks".

    @joe.edwards said:

    I'm going to asspull that Apache is the most common, in which case each VHost can have a separate configuration or just override the global settings as-needed.

    I guess what throws me is, in the absence of a file like "web.config", how does the application specify what configuration it needs? Or in Linux does that information not travel with the app at all, and the server just has to be manually configured every time? (I'm guessing the latter is the case-- ugh!)

    *) "Append the appropriate stanza to /etc/apt/sources.list. The Pgp page explains the signing of the nginx.org released packaging." Stanza? The FUCK!?


  • Considered Harmful

    @boomzilla said:

    @HardwareGeek said:
    @El_Heffe said:
    So Linux, or some variations of Linux, may not have a "rename" command that's actually built into the operating system, something that DOS 1.0 had 30 years ago.  That's the most retarded thing I've ever heard.

    Sure it does; it's just not called "rename." It's called "mv", because it can not only move a file from one name to another in the same location; it can move a file to another location, even across file system boundaries, with the same or changed name.

    Yeah, but you absolutely have to agree that it's embarrassing that the guys who created mv didn't have enough smarts to predict what DOS 1.0 would do ten years later.


    Not to mention that he totally should have predicted that PCs microcomputers would become common household and office appliances that laypeople use.



  • The embarrassing thing is that this bug has never been fixed in all those decades.



  •  Depends on what tools you know and what effects you desire. On Linux, there is more than one way for everything. I, for example, prefere to make my own packages and use the package manager to install them. Which way even the configuration is preserved (in /etc) and the manager offers me merge tool for choosing, what settings should be kept and what should be updated. But there are also other ways, how to do it.

     

     I keep getting assigned this bullshit by my boss and I'm completely incompetent to handle it.

    I fully agree, that you are incompetent. Why your bos do not give this work to some competent person instead? I would simply reject my boss, if he would try to force me to do striptease, celebral surgeon, circus acrobatics or any other work, I am incompetent to do, but my boss is too sane to want me doing such things.



  • @gilhad said:

    I fully agree, that you are incompetent. Why your bos do not give this work to some competent person instead?

    Because sadly I'm more competent than anybody else on the project. Last time we trusted a "Linux expert" at the company to set up a server, he fucked it up big-time-- I'm not a Linux expert, but I know when a server has zero back-ups, zero performance monitoring, zero redundancy, zero database indexes, etc. Even knowing jack shit about Linux, I was able to whip that server into (somewhat) decent shape.

    And the thing is he might actually have been a "Linux expert", I don't know. I'm not in position to judge, obviously. But managing a server is more than being able to use a particular operating system.


  • Considered Harmful

    @blakeyrat said:

    I guess what throws me is, in the absence of a file like "web.config", how does the application specify what configuration it needs? Or in Linux does that information not travel with the app at all, and the server just has to be manually configured every time? (I'm guessing the latter is the case-- ugh!)

    Here's where the crowdsourced nature of Linux things starts to rear its head. You can have Apache look for .htaccess files within the web root if that's how you want to do it (as I understand this is discouraged for a minor performance hit in checking these files repeatedly), and then various modules loaded into Apache like mod_rewrite and mod_php etc can each register directives for these files that they specifically know how to handle. It's not altogether that different from registering new sections of a web.config file, except it's not quite as easy to write custom handlers. If you get it wrong though, you'll be greeted with the oh-so-friendly 500 Internal Server Error. Bash your head on the wall or Google and follow random tutorials for a while - the results are comparable.


  • ♿ (Parody)

    @blakeyrat said:

    Although the web dev working on this does actually use Nginx, just looking at Nginx's installation instructions for Ubuntu* was enough for me to say "no thanks".

    You've said in the past that you understood how apt works. And you've been told before about how to use it. Again, though, I guess it's more fun to prove how much of an idiot you are and how you never learn.

    @blakeyrat said:

    The embarrassing thing is that this bug has never been fixed in all those decades.

    I suspect you're somewhere around 30 years old. Assuming you have a normal lifespan, I expect you will be a non-issue in less than 50 years.



  • @boomzilla said:

    You've said in the past that you understood how apt works.

    I do, but that's literally the first time I've heard the word "stanza" in reference to it. (I understand the musical term.) What the fuck's a "stanza?" That website doesn't explain it, and I'm not about to just flail around randomly trying to figure it out.

    The equivalent instructions for Apache were, "sudo apt-get install apache2". That I get, so that is what I put on the server.


  • Considered Harmful

    @boomzilla said:

    I suspect you're somewhere around 30 years old. Assuming you have a normal lifespan, I expect you will be a non-issue in less than 50 years.

    RESOLVED - User deceased



  • @joe.edwards said:

    You can have Apache look for .htaccess files within the web root if that's how you want to do it

    Ah, I know about .htaccess but I didn't know PHP could look for shit in there in addition to Apache itself. I've only seen it used for things like doing quick-and-dirty password protection of a directory, or overriding directory listing, or what-not.


  • Considered Harmful

    @blakeyrat said:

    (I understand the musical term.)

    For poetry it's roughly analogous to a paragraph: just a group of related lines. I wouldn't apply it to a configuration file but I could infer the meaning in that context.



  • @blakeyrat said:

    What is the best way to deploy a website to a Linux web server?

    Deployment: I only ever SFTP. But I'm always deploying to a machine I don't control so I don't get much of a choice there.

    @blakeyrat said:
    How do you keep track of application-specific configuration on Linux webservers, since they don't seem to have anything like IIS' web.config file? What if two applications have mutually-exclusive configurations?

    .htaccess (when using Apache) and php.ini are the analog to IIS's web.config. The former controls how HTTP and the file system are accessed and processed, the latter controls the script environment configuration (e.g. memory allocation, max upload size, etc.). You can use both files in a similar way that you might use web.config (as in you can put them in folders below root to only effect certain paths on the directory)

    As others have noted you take a performance hit when configuring your system in this manner. If you can control the entire instance of apache over doing folder specific configuration then you are much better off.



  • @HardwareGeek said:

    @joe.edwards said:

    @gilhad said:

    DESCRIPTION
    rename will rename the specified files by replacing the first occurrence of expression in their name by replace‐
    ment.

    That actually sounds really useful.
    Indeed. I've rolled my own using foreach and mv countless times, because I've used *nix OSs for 30 years and never knew this utility existed. Anybody know how long it's been around?

     

    The rename that comes with Ubuntu and other Debian derivatives is Larry Wall's perl rename, which is more flexible though a little more cryptic than the one described above (it uses a Perl substitution command to describe what to do to the selected filenames). Its first Debian appearance was in Potato, released in 2000.



  • @rad131304 said:

    As others have noted you take a performance hit when configuring your system in this manner. If you can control the entire instance of apache over doing folder specific configuration then you are much better off.

    Why doesn't Apache just ask the OS for notifications on those files, and only re-read the config if they change? Like IIS does? I mean... derp?



  • @blakeyrat said:

    @powerlord said:
    and they usually require it

    Who is "they"?

     

    I thought Universities was implicit there.  I guess I forgot who I was talking to.



  • @blakeyrat said:

    Serious question:

    What is the best way to deploy a website to a Linux web server?

    I could either set the web server up as a Git client and log into it and do a git update or whatever git's name for that command is, or I could set up a SFTP server and user account and we could SFTP the files to the server... the latter seems like it better separates the development process from the deployment process, and seems to be how (almost) all Linux server providers work. (Except Heroku. Which sucks.)

    How do you keep track of application-specific configuration on Linux webservers, since they don't seem to have anything like IIS' web.config file? What if two applications have mutually-exclusive configurations?

    I keep getting assigned this bullshit by my boss and I'm completely incompetent to handle it.

    For what programming language/environment?  web.config is used by the .NET languages, but even IIS doesn't support it on non-.NET languages like PHP.  Speaking of which, I really hope your boss didn't stick you with supporting PHP...

     



  • @blakeyrat said:

    Although the web dev working on this does actually use Nginx, just looking at Nginx's installation instructions for Ubuntu* was enough for me to say "no thanks".

    So I'm guessing that, as usual, you missed the part right at the start that says "Most Linux distributions and BSD variants have Nginx in the usual package repositories and they can be installed via whatever method is normally used to install software (apt-get on Debian, emerge on Gentoo, ports on FreeBSD, etc)."



  • @powerlord said:

    For what programming language/environment? web.config is used by the .NET languages, but even IIS doesn't support it on non-.NET languages like PHP.

    It does, but PHP has to add the hooks and they haven't because PHP is written by idiots.

    @powerlord said:

    Speaking of which, I really hope your boss didn't stick you with supporting PHP...

    Yeah, but 99% of the project is raw HTML/JS/CSS, the PHP script is just like 30 lines to do a OAuth bullshit thing I dunno whatever



  • @blakeyrat said:

    @boomzilla said:
    You've said in the past that you understood how apt works.

    I do, but that's literally the first time I've heard the word "stanza" in reference to it. (I understand the musical term.) What the fuck's a "stanza?" That website doesn't explain it, and I'm not about to just flail around randomly trying to figure it out.

    The equivalent instructions for Apache were, "sudo apt-get install apache2". That I get, so that is what I put on the server.

     

    "sudo apt-get install nginx" has worked on Ubuntu for several years at least.  I have no idea why they suggest adding different nginx repositories to install it. For Ubuntu/Debian, the [url=http://www.binarytides.com/install-nginx-php-fpm-mariadb-debian/]Debian 7 guide[/url] isfar more useful than the standard documentation.

     



  • @blakeyrat said:

    @powerlord said:
    For what programming language/environment? web.config is used by the .NET languages, but even IIS doesn't support it on non-.NET languages like PHP.

    It does, but PHP has to add the hooks and they haven't because PHP is written by idiots.

    @powerlord said:

    Speaking of which, I really hope your boss didn't stick you with supporting PHP...

    Yeah, but 99% of the project is raw HTML/JS/CSS, the PHP script is just like 30 lines to do a OAuth bullshit thing I dunno whatever

    PHP is full of wtfs all over.  .htaccess (for Apache) or manually defining parameters directly in Apache's virtualhost for PHP is the only way to override any of PHP's main settings.  And even that's not available if PHP is running in FCGI mode instead of as the Apache module.


Log in to reply