LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-23-2004, 03:21 AM   #16
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910

What do you get in cygwin when you try
echo "Test" > test
?

Even that emulation can't be THAT bad...


Cheers,
Tink
 
Old 03-23-2004, 03:25 AM   #17
Bebo
Member
 
Registered: Jul 2003
Location: Göteborg
Distribution: Arch Linux (current)
Posts: 553

Rep: Reputation: 31
Ohnoooo...! I'm sorry VisionZ, I gave you a script which is a bit too specific in the wrong places. You see the line with the find command? It says it should find files under /usr/local/bin, which is where I have my scripts I did this just to test the script, but I forgot to change it when I posted it. OK, let's see now... I take som ideas from Tink's script now

Code:
#!/bin/sh

SCRIPTNAME=~/archiver

if [ x`echo $1` = x ] ; then
   ARCHIVEDIR=`pwd`
else
   ARCHIVEDIR="$1"
fi

ARCHIVE=${ARCHIVEDIR}/scripts.tar

find $ARCHIVEDIR -type f | while read FILE ; do
   BASHSCRIPT=`file "$FILE" | grep Bourne | grep -c "shell script text executable"`

   if [ $BASHSCRIPT -eq 1 -a "$FILE" != "$SCRIPTNAME" ] ; then
      echo "Archiving $FILE in $ARCHIVE"
      tar rf $ARCHIVE $FILE
   fi
done
 
Old 03-23-2004, 05:07 AM   #18
VisionZ
Member
 
Registered: Mar 2004
Posts: 58

Original Poster
Rep: Reputation: 15
OK I think it may have worked, but I cant find a tar archive??? it should be in my home correct? What is its name also, scripts.tar??

except I get no output, it just sits there and waits, then goes back to the prompt. I get no echoing or any output at all.

I really do appreciate both of your guys help and paitence, hopefull I can attain your level of skill someday kudos to both of you.

Tink - to answer your question when I make a script out of

echo "Test" > test

nothing happens, when i type it in the cygwin terminal nothing happens

it just goes to the next prompt.
 
Old 03-23-2004, 05:36 AM   #19
Bebo
Member
 
Registered: Jul 2003
Location: Göteborg
Distribution: Arch Linux (current)
Posts: 553

Rep: Reputation: 31
Yes, the tar archive is called scripts.tar and should be in your home dir. This is very strange... My script might fail if the file command doesn't work as I think. Try issue file oneofyourscripts and see what the output is. What my script looks for is output of the form "Bourne-Again shell script text executable" or "Bourne shell script text executable". If, for some reason, this isn't echoed, then my script won't work.

Sorry for confusing you; maybe I'm just stupid and write bad scripts
 
Old 03-23-2004, 06:13 AM   #20
VisionZ
Member
 
Registered: Mar 2004
Posts: 58

Original Poster
Rep: Reputation: 15
No it probably is working just fine, but is an issue with my cygwin for windows or something. Let me try
file rmv~
a script i wrote to get rid of the extra ~ files emacs makes
and see what happens.
 
Old 03-23-2004, 06:14 AM   #21
VisionZ
Member
 
Registered: Mar 2004
Posts: 58

Original Poster
Rep: Reputation: 15
when i try this it says

rmv~: cannot open (rmv~).

thats all it says
 
Old 03-23-2004, 06:16 AM   #22
VisionZ
Member
 
Registered: Mar 2004
Posts: 58

Original Poster
Rep: Reputation: 15
what are you guys using as a text editor?? is it wordpad and you create txt files or are you guys using emacs or vim? Or something else I dont know about.
 
Old 03-23-2004, 06:43 AM   #23
Bebo
Member
 
Registered: Jul 2003
Location: Göteborg
Distribution: Arch Linux (current)
Posts: 553

Rep: Reputation: 31
I'm usually using emacs or pico, vi/vim when I'm forced to it

That file error message looks odd to me. Another possibility is to rewrite the BASHSCRIPT "boolean" to look for the string "#!/bin/" in every file:
Code:
BASHSCRIPT=`grep -c "\#\!/bin/" "$FILE"`
 
Old 03-23-2004, 07:31 AM   #24
VisionZ
Member
 
Registered: Mar 2004
Posts: 58

Original Poster
Rep: Reputation: 15
I,ll give it a try, and and well this is what happened



IT WORKED!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
now one more SMALL thing how do I make it not archive itself, and to check and see if the archive it is making already exists, I dont want to archive over a previous archve, maybe just add a 1 and so on to the end or something if that is not to complicated
 
Old 03-23-2004, 11:08 AM   #25
Bebo
Member
 
Registered: Jul 2003
Location: Göteborg
Distribution: Arch Linux (current)
Posts: 553

Rep: Reputation: 31
To solve the problem with its archiving itself in a nice way I'd first like to know a way to expand directory names such as ./blah and ../../blah, or ~/blah to the proper full path name. This is something I haven't learned yet
 
Old 03-24-2004, 12:15 AM   #26
VisionZ
Member
 
Registered: Mar 2004
Posts: 58

Original Poster
Rep: Reputation: 15
Again Thanks a ton for your help I,m Afferoing ya
 
Old 03-24-2004, 02:59 AM   #27
Bebo
Member
 
Registered: Jul 2003
Location: Göteborg
Distribution: Arch Linux (current)
Posts: 553

Rep: Reputation: 31
Gee thanks But can you do that? I haven't signed up...
 
Old 03-24-2004, 03:40 AM   #28
VisionZ
Member
 
Registered: Mar 2004
Posts: 58

Original Poster
Rep: Reputation: 15
I dont know, I,ll figure it out though, I left feedback =)
Not only am I new to linux I,m new to linuxquestions.com
But you all have inspired me to parition some of my HD to Slackware
screw this cygwin BS!
 
Old 03-25-2004, 06:25 PM   #29
Bebo
Member
 
Registered: Jul 2003
Location: Göteborg
Distribution: Arch Linux (current)
Posts: 553

Rep: Reputation: 31
Hello again, VisionZ and spectators I've solved your problem now, I think:
Code:
#!/bin/sh

ARCHIVEBASENAME=scripts

if [ x`echo $1` = x ] ; then
   SEARCHDIR=.
else
   SEARCHDIR="$1"
fi
  
NUMBER=1
while [ -f "${ARCHIVEBASENAME}${NUMBER}.tar" -o -f "${ARCHIVEBASENAME}${NUMBER}.tar.gz" ] ; do
   NUMBER=$((NUMBER + 1))
done

ARCHIVE=${ARCHIVEBASENAME}${NUMBER}.tar

if [ -d "$SEARCHDIR" ] ; then
   find "$SEARCHDIR" -type f | while read FILE ; do
      ISSCRIPT=`grep -c "\#\!/bin/" "$FILE" 2> /dev/null`
      
      [ $? -gt 0 ] && ISSCRIPT=0
      
      if [ $ISSCRIPT -eq 1 ] ; then
         if [ ! "$FILE" -ef "$0" ] ; then
            echo "Archiving $FILE in $ARCHIVE.gz"
            tar rf "$ARCHIVE" "$FILE"
         fi
      fi   
   done    

   [ -f "$ARCHIVE" ] && gzip "$ARCHIVE"
fi
Well, this was fun, we have to do it again some time
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Copy files from multiple directories into one directory MadRabbit Linux - Newbie 8 02-07-2014 08:56 PM
Searching multiple directories and sub directories for a file jeep99899 Linux - Newbie 2 10-13-2005 01:23 PM
find and copy files into multiple directories avargas22 Linux - Newbie 2 04-01-2004 12:11 PM
un-tarring multiple files phil1076 Linux - General 19 12-18-2003 03:03 PM
tar multiple directories computera Linux - General 2 11-17-2001 08:27 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:30 PM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration