LinuxQuestions.org
Help answer threads with 0 replies.
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 05-30-2012, 08:30 AM   #1
lleb
Senior Member
 
Registered: Dec 2005
Location: Florida
Distribution: CentOS/Fedora/Pop!_OS
Posts: 2,983

Rep: Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551
what is lighter on the system, variable calls, or full path in BASH script?


example:
Code:
#!/bin/bash
OLD=/tmp/old
LOCAL=`pwd`
cp -Ravf $OLD/foo.* $LOCAL
or
Code:
#!/bin/bash
LOCAL=`pwd`
cp -Ravf /tmp/old/foo.* $LOCAL
This is just an example, but if i were to use the 2nd option to copy say 30-40 specific files/types of files would that be lighter on the system, then the option with 1 variables, or does it really matter. typically this would be run ONCE on a system to transfer data from old computer to new.
 
Old 05-30-2012, 08:37 AM   #2
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 23,010

Rep: Reputation: 7627Reputation: 7627Reputation: 7627Reputation: 7627Reputation: 7627Reputation: 7627Reputation: 7627Reputation: 7627Reputation: 7627Reputation: 7627Reputation: 7627
in case you want to copy 30-40 files (or less than a few thousands) it does not matter at all.
variables are used to write better scripts (which can be handled easier)
 
Old 05-30-2012, 10:40 AM   #3
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fedora-35
Posts: 5,326

Rep: Reputation: 919Reputation: 919Reputation: 919Reputation: 919Reputation: 919Reputation: 919Reputation: 919Reputation: 919
variables are stored in ram.
 
Old 05-30-2012, 01:39 PM   #4
lleb
Senior Member
 
Registered: Dec 2005
Location: Florida
Distribution: CentOS/Fedora/Pop!_OS
Posts: 2,983

Original Poster
Rep: Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551
Quote:
Originally Posted by pan64 View Post
in case you want to copy 30-40 files (or less than a few thousands) it does not matter at all.
variables are used to write better scripts (which can be handled easier)
let me be more specific, there can be thousands of files, but we are talking file type extension, etc... like .dat and .idx from the data base, etc...

if it really does not matter, then ill leave it in simple plan text without creating any functions, or what not.

Thank you both.
 
Old 05-30-2012, 01:45 PM   #5
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 23,010

Rep: Reputation: 7627Reputation: 7627Reputation: 7627Reputation: 7627Reputation: 7627Reputation: 7627Reputation: 7627Reputation: 7627Reputation: 7627Reputation: 7627Reputation: 7627
I think it really does not matter, copying files will take much more time






__________________________________
Happy with solution ... mark as SOLVED
If someone helps you, or you approve of what's posted, click the "Add to Reputation" button, on the left of the post.
 
Old 05-30-2012, 01:47 PM   #6
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,573

Rep: Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142
The variable expansion is only performed once on the call to copy, it doesn't matter how many files are actually copied. If you're only calling the copy 30-40 times, then you're only doing the variable expansion 30-40 times, and it will have no effect on the speed of the process. If this was inside a high speed loop that was iterating thousands/millions of times in a matter of seconds, then it might start to make a difference, but the copy itself will use FAR more time than the variable expansion in this case, so it'll make no practical difference.

Last edited by suicidaleggroll; 05-30-2012 at 01:48 PM.
 
Old 05-30-2012, 01:53 PM   #7
lleb
Senior Member
 
Registered: Dec 2005
Location: Florida
Distribution: CentOS/Fedora/Pop!_OS
Posts: 2,983

Original Poster
Rep: Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551
fantastic, thanks all.
 
  


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
[SOLVED] bash script - return full path and filename Andy Alt Programming 44 01-10-2013 10:11 AM
[SOLVED] Failed miserably to execute bash script via PATH variable after FS migration. kopatops Linux - Software 21 08-18-2010 07:34 AM
a script calls another script which calls "bash" inside lordofring Linux - Software 10 03-18-2010 10:59 AM
bash script path issue - how to pass a path as a string to a variable PiNPOiNT Programming 5 04-17-2009 06:48 PM
Is 'nice' inherited to child processes? e.g. bash script/php script that calls MySQL SirTristan Linux - Newbie 1 12-04-2008 01:57 AM

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

All times are GMT -5. The time now is 11:07 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