Understanding FIND

hi

hope this is the right place for noob questions

i'm struggling with this example:

Code:
$ find . -name temp -prune -o -print
from theunixschool.com

it means:
Find all the files except the ones under the temp directory.

shouldn't it be:
Code:
$ find . -path temp -prune -o -print

thx!


Similar Content



Trailing Slash Or Not?

When I type in a path to a directory - whether it be in SSH or a config file or wherever - should I end it with a trailing slash or not?

For example...
Code:
/home/rob123/temp/

or

Code:
/home/rob123/temp


Rob

Ubuntu Directories

Hi there. I have Ubuntu 14.04 installed. Actually I have been doing a lot of work in this OS for about a year. The thing I cannot still comprehend is how to find files I installed. In this particular case I need glut.h for g++ compiler. So I go here, do this command;

Code:
sudo apt-get install freeglut3-dev

And find out that I already have the newest version (which I have suspected since I recall installing it).

So, the next step is to find the glut.h file and reference it with #include command. I cannot find it anywhere. This website says it has to be he

Code:
/usr/lib/x86_64-linux-gnu/libglut*

Why's the asterisk? Is it a footnote or part of the code?

I don't seem to have /usr/ directory. I cannot find it anywhere.

How does Ubuntu directory work?

Thanks, - A.

After Install Gpsr, Test The Perimeter Mode , It Has Throw "Wrong The Other Node"

hello there!
the common communication between nodes is fine, but when i want to test the perimeter mode it has throw the error "Wrong the other node", it seems that it couldn't find its next hop node.
i trace the code as show below
Code:
int
GPSRNeighbors::intersect(nsaddr_t theother, double sx, double sy,
			 double dx, double dy){
  //line 1 (x1,y1)--(x2,y2) is the segment
  //line 2 (x3,y3)--(x4,y4) is the xD 
  struct gpsr_neighbor *other = getnb(theother);

  if(other==NULL){
    printf("Wrong the other node\n");
    exit(1);
  }


  ****************

struct gpsr_neighbor*
GPSRNeighbors::getnb(nsaddr_t nid){
  struct gpsr_neighbor *temp = head_;
  while(temp){
    if(temp->id_ == nid){
      if((GPSR_CURRENT - temp->ts_) < DEFAULT_GPSR_TIMEOUT)
	return temp;
      else {
	delnb(temp); //if this entry expire, delete it and return NULL
	return NULL;
      }
      return temp;
    }
    temp = temp->next_;
  }
  return NULL;
}

the simulation scene was shown in the attachment.
when i make node 0 send packet to node 1, the error will occur.
would somebody know how to solve it?
thank you for your time!

Find 30 Days Old And Delete Prints Error Msg File Not Found After Deleting It

I have a shell script to find folders which are 25 days older and delete it, and put the deleted folder details into log file like this

Code:
 find /ahome/xxx/$FOLDER -type d -mtime +25  -exec ls -ld {} \;  -exec rm -rf {} \;  >> mylogfile.log

after running this command it deletes the folder and logs the folder deleted. But also print error msg
Code:
find: /ahome/prksh/dir/test: No such file or directory

How to suppress the error msg

Command Manual Working But Not On Cron

Hi

When i run this command manually on Centos 6.6 it works:

Code:
/usr/bin/find /backup/ -type d -mtime +1 -print0 | xargs -0 rm -rf

but as a cron job it doesn't as i can see a folder with files there from Mar 28:

Code:
55 5 * * * /usr/bin/find /backup/ -type d -mtime +1 -print0 | xargs -0 rm -rf

And here are the logs from cron that it is executing this at the correct time :

Code:
Mar 30 05:55:01 server CROND[9526]: (root) CMD (/usr/bin/find /backup/ -type d -mtime +1 -print0 | xargs -0 rm -rf)

Any ideas why?

Thanks

Using Find And Pipe To Tar

am trying to use tar in combination with find, the goal is to all files in /export that have been modified in the last 24 hours (back up purposes), then tar them so I can untar on the backup server, updating just the modified files.

Perhaps there is a better way, however, I have tried using cpio but the problem come in when I copy to the NAS drive (NTFS) I lose all my owner/group and permissions. I have found that if I tar the files, then copy them to the NAS, when I untar on the server, it will retain the owner/group and permissions.

So… here is what I have tried:

First, I use the find command to see what files should be in the tar archive.
Code:
/export $ find . -depth -mtime 0 -print
./file4
./file3
.

Ok, that looks right, now I will try to pipe that in to tar
Code:
/export $ find . -depth -mtime 0 -print0 | tar -czvf backup.tar.gz --null -T - 
./file4
./file3
./
./share/
./share/pdf/
./share/pdf/penny-2014-09-03-11:41.30.pdf
./share/pdf/penny-2014-09-03-14:25.17.pdf
./share/pdf/penny-2014-09-03-11:24.36.pdf
./share/pdf/penny-2014-09-03-14:37.12.pdf
tar: ./share/pdf/.directory: Cannot open: Permission denied
./share/pdf/penny-2014-09-02-14:52.06.pdf
./share/pdf/penny-2014-09-03-12:18.43.pdf
tar: ./share/PDF: Cannot open: Permission denied
./share/file3
tar: ./share/.directory: Cannot open: Permission denied
./dir1/
./dir1/file1
./file4
./file2
./file3
tar: ./.directory: Cannot open: Permission denied
./list
tar: Exiting with failure status due to previous errors

It seems that it is trying to tar all the files in that directory. When I view the files in backup.tar.gz all of the files from /export are in there not just the modified ones

Stdout, Stderr And Redirection -- What Is The Correct Order Or Format ?

Hi all,

Been reading on stdin, stdout and stderr and encounter 2 questions, hope gurus here can advise.

0 = stdin
1 = stdout
2 = stderr

Code:
Sun Dec 21 03:53:42 SGT 2014 > cat test5.sh
#!/bin/bash

echo "Please enter value for name :"
read name
echo "Your name is $name."

echo "Next echo will be a syntax error"
ehco

Code:
Sun Dec 21 03:53:46 SGT 2014 > test5.sh 1> output.txt 2> error.txt
Noob

Sun Dec 21 03:54:56 SGT 2014 > cat output.txt
Please enter value for name :
Your name is Noob.
Next echo will be a syntax error

Sun Dec 21 03:55:23 SGT 2014 > cat error.txt
/home/alan/scripts/test5.sh: line 8: ehco: command not found
Sun Dec 21 03:55:26 SGT 2014 >

Which so far all is good and the correct way to output everything including error to a single file is

Code:
Sun Dec 21 03:59:14 SGT 2014 > test5.sh > output.txt 2>&1


Q1) How is a command being interpreted in linux , the sequence in which it is interpreted ? from left to right ? right to left ?

Shouldn't it be

Code:
test5.sh 2>&1 1>output.txt 
or 
test5.sh 2>&1>output.txt ?

Regards,
Noob

Diffing The Line Numbers

hi guys

i am trying to find the "size" of a "block" of data in LARGE data files, the example below test_data.txt is very simplified. by "size" i mean the difference in line numbers of a block, and the "size" will be constant throughout the file so

1234 6.600000 4321
1234 8.500000 4321
1234 1.800000 4321
1234 2.300000 4321
1234 8.500000 4321
1234 2.800000 4321

if i define a block as whenever i find 8.500000 in the second column, then in the example the the block size would be 3 becasue 8.500000 occurs on the 5th line and on the 2nd. right now i am using

Code:
 grep -n "8.500000" test_data.txt | cut -f1 -d:

and/or

Code:
 awk '/8.500000/ {print FNR}' test_data.txt

obviously i don't remeber how to tag text as code?

btw, the grep command is much much faster

both of these commands give an entire list (long list of number for files greater than a gig) of line numbers which i then have to subtract one from another to come up with 3 in the example. not that i'm opposed to doing math, but i would think awk or grep should be able to do this for me

ideas?

tabby

Python Ftplib

hello all,

please help me with python ftplib. i was trying to copy files from my linux machine to a windows server using ftplib. everything was working good. but i'm only able to copy files from the same directory the script is. how do i copy files from a different directory? i always get "file not found error message". here's my code :

Code:
tester_name = str (socket.gethostname())
def upload(ftp, file):
    ext = os.path.splitext(file)[1]
    if ext in (".txt", ".htm", ".html"):
        ftp.storlines("STOR " + file, open(file))
    else:
        ftp.storbinary("STOR " + file, open(file, "rb"), 1024)



parse_source_path = ('/path/to/where/i/go/')
parse_source_file_list = os.listdir(parse_source_path)

ftp = ftplib.FTP("server_IP")
ftp.login("username", "pass")

folder_list = []

ftp.dir(folder_list.append)

if str(tester_name) not in str(folder_list) :
    ftp.mkd("%s"%tester_name)
    ftp.cwd("%s"%tester_name)
    for files in parse_source_file_list :
        print files
        upload(ftp, files)


else :
    print "later"

Error In A Variable

Hi,
Someone could help me with these sentence?
Code:
per=`print "scale=2; $sum/$count" | bc`

It says me:
Code:
(standard_in) 1: parse error

Why?