LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
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-22-2023, 05:08 PM   #16
metaed
Member
 
Registered: Apr 2022
Location: US
Distribution: Slackware64 15.0
Posts: 385

Rep: Reputation: 177Reputation: 177

Contrary to the Bash FAQ, I value the visual difference of `` for command substitution, $ for symbol substitution. I can tell at a glance when I'm dereferencing a shell variable and when I'm creating a subshell.

I admit this is due to having a legacy brain. Legacy brains that still run legacy shell are inevitably going to write legacy shell scripts. And backtick command substitution is the go-to for true compatibility with legacy brains (and shells).
 
1 members found this post helpful.
Old 03-22-2023, 05:40 PM   #17
jrosevear
LQ Newbie
 
Registered: Nov 2006
Distribution: Slackware
Posts: 29

Rep: Reputation: 14
Quote:
Originally Posted by boughtonp View Post
It's a bug in the script - it incorrectly splits quoted arguments.

Code:
$ tail example{1,2}.sh
==> example1.sh <==
#!/bin/sh
file $*
==> example2.sh <==
#!/bin/sh
file "$@"

$ ./example1.sh test_file1 'test file2'
test_file1: ASCII text
test:       cannot open `test' (No such file or directory)
file2:      cannot open `file2' (No such file or directory)

$ ./example2.sh test_file1 'test file2'
test_file1: ASCII text
test file2: ASCII text
Hello boughtonp,

Thank you for your reply.

I tried your example above and it confirmed my understanding. I agree with you about the behavior of $* and "$@". I think this is an important bit of knowledge and very much a worthwhile thing to talk about.

I suppose that it is, in fact, a bug. Especially so if it bites you.

-Joe
 
Old 03-22-2023, 07:32 PM   #18
Llyich
LQ Newbie
 
Registered: Mar 2023
Location: Switzerland
Distribution: PC Xubuntu/Devuan laptop Xubuntu 12.04 LTS
Posts: 7

Original Poster
Rep: Reputation: 0
Thank you for yours answers

Hello jrosevear,
Thank you for your response and for your interest in the links.

Test
Before ordering:
Physical source
/media/serv/ja05/rm/source.mkv
Link:
/home/serv/Link/00/source.mkv -> /media/serv/ja05/rm/source.mkv)
Purpose:
/media/serv/ja05/000

Command (jrosevear response):
Quote:
mv `readlink -f "/home/serv/Lien/00/source.mkv"` "/media/serv/ja05/000"
After the command:
Physical source
/media/serv/ja05/rm/source.mkv
Link:
/home/serv/Link/00/source.mkv -> /media/serv/ja05/rm/source.mkv
Purpose:
/media/serv/ja05/000/source.mkv

Additionals commands:
rm `readlink -f "/home/serv/Lien/00/source.mkv"`
rm /home/serv/Link/00/source.mkv

After the additionals commands:
Physical source
/media/serv/ja05/rm/
Link:
/home/serv/Link/00/
Purpose:
/media/serv/ja05/000/source.mkv

This is an mv on the same ja05 hard drive, source.mkv is several Gio in size, the command was instant, instead of 10 minutes using a cp -rvL

Kind regards,
Llyich
 
Old 03-22-2023, 10:20 PM   #19
jrosevear
LQ Newbie
 
Registered: Nov 2006
Distribution: Slackware
Posts: 29

Rep: Reputation: 14
Quote:
Originally Posted by Llyich View Post
Hello jrosevear,
Thank you for your response and for your interest in the links.

Test
Before ordering:
Physical source
/media/serv/ja05/rm/source.mkv
Link:
/home/serv/Link/00/source.mkv -> /media/serv/ja05/rm/source.mkv)
Purpose:
/media/serv/ja05/000

Command (jrosevear response):


After the command:
Physical source
/media/serv/ja05/rm/source.mkv
Link:
/home/serv/Link/00/source.mkv -> /media/serv/ja05/rm/source.mkv
Purpose:
/media/serv/ja05/000/source.mkv

Additionals commands:
rm `readlink -f "/home/serv/Lien/00/source.mkv"`
rm /home/serv/Link/00/source.mkv

After the additionals commands:
Physical source
/media/serv/ja05/rm/
Link:
/home/serv/Link/00/
Purpose:
/media/serv/ja05/000/source.mkv

This is an mv on the same ja05 hard drive, source.mkv is several Gio in size, the command was instant, instead of 10 minutes using a cp -rvL

Kind regards,
Llyich
Hello Llyich,

Thank you for your reply.

I'm afraid I don't understand. Would you like to send me an email in your native language? My email is Mail@JoesLife.org

-Joe
 
Old 03-23-2023, 03:24 AM   #20
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 22,138

Rep: Reputation: 7375Reputation: 7375Reputation: 7375Reputation: 7375Reputation: 7375Reputation: 7375Reputation: 7375Reputation: 7375Reputation: 7375Reputation: 7375Reputation: 7375
Quote:
Originally Posted by boughtonp View Post
I've no idea why Pan64 wrote "I guess you wanted to use bash, not sh (see your shebang)" - there's no Bash-specific syntax there, so no benefit in requiring Bash.
If it's intentionally /bin/sh, it's perfectly fine. I just wasn't sure, and using sh instead of bash (unintentionally) might cause surprises.
 
  


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
oops - made a file called "--dereference" - how do I delete it? BrianK Linux - General 2 06-21-2004 08:37 PM
Strange kernel error: "Unable to handle kernel NULL pointer dereference..." EcceVery Debian 4 04-12-2004 06:34 AM
Unable to handle kernel NULL pointer dereference.... kadaver Slackware 2 12-19-2003 07:46 AM
Unable to handle kernel NULL pointer dereference at virtual ...? severedhead Linux - Software 0 07-12-2002 04:46 PM
Kernel Message:unable to handle kernel NULL pointer dereference at virtual address... dave_d Linux - General 0 02-14-2001 05:01 PM

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

All times are GMT -5. The time now is 01:43 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
Open Source Consulting | Domain Registration