LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 08-26-2004, 05:06 AM   #1
tonton
LQ Newbie
 
Registered: Aug 2004
Posts: 4

Rep: Reputation: 0
Syntaxe error "find"


hello,

i want to find files "toto*"

after, i want to display all files found without the 3rd first lignes for each file in a new "titi"

in this new file "titi", i want to have on the end of each ligne, the name of the directory.

to make this, i use :

for j in $i
do
find ./ -name "$toto*" -exec tail +3 {} | "$j" \; >> titi
done

it doesn't work.

Thanks for your help
 
Old 08-26-2004, 05:26 AM   #2
bigearsbilly
Senior Member
 
Registered: Mar 2004
Location: england
Distribution: Mint, Armbian, NetBSD, Puppy, Raspbian
Posts: 3,515

Rep: Reputation: 239Reputation: 239Reputation: 239
what's the purpose of the 'for' loop?

you cannot put a pipe '|' in the middle of the -exec option.
the "$toto*" should be 'toto*' single quotes, otherwise it will only
find in the current directory.
 
Old 08-26-2004, 05:43 AM   #3
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,362

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
I'm not quite clear on exactly what you want, I'm guessing English is not your 1st language, but that's not important
I think to start with that you want all files beginning with 'toto', you want to remove the 1st 3 lines and concatenate (collect/append) all the results into a file called 'titi'.

This shoud do that:

Code:
for file in `find . -name 'toto*' -print 2>/dev/null`
do
    result=`tail +4 $file`
    echo $result >> titi
done
I'm not sure which directory you want appended to each line? If it's the one each 'toto*' file is in, it'll be repeated for each line of that file. Is that really what you want?

HTH
 
Old 08-27-2004, 07:34 AM   #4
infernal
Member
 
Registered: Oct 2001
Location: /dev/null
Distribution: Debian, Slackware
Posts: 44

Rep: Reputation: 15
Assuming this is the format of the titi file that you want to create
Code:
lines of toto1
/path/to/toto/1

lines of toto2
/path/to/toto2

lines of totoN
/dir/of/totoN
...
these are the params of find to solve the problem:
Code:
find . -name 'toto*' -type f -exec tail +4 {} >> titi \; -exec printf "--- file {}\n\n" >> titi \;
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Shell Script: Find "Word" Run "Command" granatica Linux - Software 5 07-25-2007 07:42 AM
E17 compile error edje cannot find "brushed.png" inkysplat Linux - Software 1 01-06-2006 12:48 AM
Can't install "glibmm" library. "configure" script can't find "sigc++-2.0&q kornerr Linux - General 4 05-10-2005 02:32 PM
UT demo error: "Can't find file for package 'SDLGLDrv'" r_jensen11 Linux - Software 2 04-13-2004 09:49 PM
make error "libtool: link: cannot find the library `' " jdolluc Linux - Software 2 10-15-2003 09:51 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:56 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration