'ls' in terminal trouble (=

This is a discussion on 'ls' in terminal trouble (= within the Linux Programming forums, part of the Platform Specific Boards category; Well I was doing some examples of c programs when I noticed that one of my programs I tested is ...

  1. #1
    Registered User
    Join Date
    May 2007
    Posts
    45

    'ls' in terminal trouble (=

    Well I was doing some examples of c programs when I noticed that one of my programs I
    tested is now showing up when I type "ls" in the terminal. I don't mean the name of the
    program I mean its actually showing me this when I type "ls" so how can I fix this ):

    Code:
     
    wrath@wrath-desktop:~/test$ ls
    a.out
    #include <stdio.h>?? int main(void)? {?   int ch;??   while ((ch = getchar()) != EOF)?     
    putchar(ch);?   putchar('\n');?   ?   return 0;? }?~
    test.c
    Is this common ?


    O and if anyones feeling generous Im looking for some common commands for the terminal,
    mainly to delete a file after I test it, rename it. I'm sure I can easily find this out when I go
    googling (weird spell checker says that isn't a word (= Must be by now) later so no problem i
    f you don't wont to help me there (=

    Thanks in advance (=
    -Raven's Wrath

  2. #2
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,211
    I hate to ask this, but did you rename ls or make a new ls executable inside that directory?

  3. #3
    Registered User
    Join Date
    May 2007
    Posts
    45
    rename ls? no I don't think I could if I wanted too (=

  4. #4
    Captain Crash brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,274
    It just looks like a funny filename, probably created by a wrong shell command. Try to rename it by doing mv *include* renamed. If it then shows up as a file called "renamed" you can just delete it. If it doesn't, something weirder is going on.

    EDIT: Also, what do you get when you do "which ls" ?
    Last edited by brewbuck; 05-17-2007 at 01:33 AM.

  5. #5
    Registered User
    Join Date
    May 2007
    Posts
    45
    I can't find the file (if it is a file) to rename or delete it )=

    My folder is compelty empty now, but it still says its in there )=

    I get /bin/ls

    Any ideas? (=
    Last edited by Ravens'sWrath; 05-17-2007 at 01:42 AM. Reason: edit

  6. #6
    Captain Crash brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,274
    How do you figure the folder is empty if ls shows a file in it? If you type "rm #" and then hit the Tab key what happens?

  7. #7
    Registered User
    Join Date
    May 2007
    Posts
    45
    I know its telling me a file is in the folder... But there is nothing in the folder when I check )=
    When I type that all I get is a beep and this "rm: cannot remove `#': No such file or directory
    "

  8. #8
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,851
    Code:
    $ ls --help
    Usage: ls [OPTION]... [FILE]...
    List information about the FILEs (the current directory by default).
    Sort entries alphabetically if none of -cftuvSUX nor --sort.
    
    Mandatory arguments to long options are mandatory for short options too.
      -a, --all                  do not ignore entries starting with .
      -A, --almost-all           do not list implied . and ..
          --author               with -l, print the author of each file
      -b, --escape               print octal escapes for nongraphic characters
    Use -a to get all files, including hidden ones which begin with .
    Use -b to stop your terminal going haywire if there are funny characters.

    If you want to remove hard to type filenames, then do something like
    Code:
    rm -i *pattern*
    where pattern is something which almost matches the printable part of the filename, then answer 'y' to the one you want to get rid of.

    Another way is to do
    Code:
    ls -lbi
    to list all filenames in printable form, along with inode numbers.

    Then do
    Code:
    find . -inum nnnnnn -exec rm -f {} \;
    where nnnnnn is the inode number of the awkward file that you want to get rid of.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  9. #9
    Registered User
    Join Date
    May 2007
    Posts
    45
    Thanks for that information Salem, I ended up deleting the directory that I had the file in or I'd give them a test. If I get the same problem again I shall try what you have said.

    Thanks,
    Raven's Wrath.

  10. #10
    Captain Crash brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,274
    Quote Originally Posted by Ravens'sWrath View Post
    Thanks for that information Salem, I ended up deleting the directory that I had the file in or I'd give them a test. If I get the same problem again I shall try what you have said.

    Thanks,
    Raven's Wrath.
    I'm kind of disappointed that we didn't figure out where this file came from. I've never seen such a problematic filename, at least on a Linux system. I really think that "rm *include*" should have worked.

    Do you have any idea how the file was created? Were you experimenting with any new shell commands around the same time it happened?

  11. #11
    Linux is where it's at movl0x1's Avatar
    Join Date
    May 2007
    Posts
    72
    mv filename newfilename renames a file

    cp filename newfilename copies a file

    rm filename removes a file

    type man mv, man rm, etc to learn more options for those
    commands



Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem Clearing Terminal
    By mrginger in forum C Programming
    Replies: 3
    Last Post: 04-15-2009, 12:58 PM
  2. Console, Terminal and Terminal Emulator
    By lehe in forum C Programming
    Replies: 4
    Last Post: 02-15-2009, 09:59 PM
  3. version of ls -l bug, only takes cwd :(
    By chl12 in forum C Programming
    Replies: 2
    Last Post: 06-12-2007, 03:44 AM
  4. Turtle CVS and sourceforge, no 'ls'
    By nickname_changed in forum A Brief History of Cprogramming.com
    Replies: 0
    Last Post: 08-05-2003, 04:19 AM
  5. Controlling terminal tty
    By pdstatha in forum C Programming
    Replies: 0
    Last Post: 04-02-2002, 03:57 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21