LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 10-22-2022, 04:16 PM   #1
Catball
LQ Newbie
 
Registered: Oct 2022
Posts: 4

Rep: Reputation: 0
[Solved] What does %f, %c, or %a mean in Bash?


Hi,

Newbie here
What do %a, %f and %c mean in the following code?

Code:
if [ -n "%a" ]; then
zip -r '%a.zip' %f;
elseif [ "%c" = "%f" ]; then
zip -r %c.zip %c;
else
zip -r %d:t.zip %f;
fi
I have only some basic knowledge of Bash. I tried to google this, but couldn't find an answer.

Last edited by Catball; 10-22-2022 at 06:02 PM.
 
Old 10-22-2022, 04:48 PM   #2
teckk
Senior Member
 
Registered: Oct 2004
Distribution: Arch
Posts: 4,448
Blog Entries: 5

Rep: Reputation: 1548Reputation: 1548Reputation: 1548Reputation: 1548Reputation: 1548Reputation: 1548Reputation: 1548Reputation: 1548Reputation: 1548Reputation: 1548Reputation: 1548
For the first part see:
Code:
man test
Code:
a=1
if [ -n "$a" ]; then
    echo "the length of a is nonzero"
fi
For the zip command see:
Code:
man zip
-r is recursive.

Couple other examples:
Code:
name="Linux"
printf "%s\n" "${name%%n*}"
Li

b=MyFile.txt
basename=${b%.*}
echo "$basename"
MyFile

array=(This is an array with elements)
echo "${array[@]%is}"
Th  an array with elements
 
Old 10-22-2022, 04:57 PM   #3
michaelk
Moderator
 
Registered: Aug 2002
Posts: 23,677

Rep: Reputation: 5184Reputation: 5184Reputation: 5184Reputation: 5184Reputation: 5184Reputation: 5184Reputation: 5184Reputation: 5184Reputation: 5184Reputation: 5184Reputation: 5184
Welcome to LinuxQuestions.

I assume %a, %f and %c are variables but they should be $a,$f and $c.
Where did you get the example code?

To assign something to a variable
a=1
to use the variable you would precede it with a $ i.e.
echo $a
 
Old 10-22-2022, 05:16 PM   #4
Catball
LQ Newbie
 
Registered: Oct 2022
Posts: 4

Original Poster
Rep: Reputation: 0
@teckk

Thank you for your reply.

I didn't have any problem with the if or the zip part.
I also know what $ means in Bash.
What I didn't (and still don't) know is the
Quote:
%a, %c and %f
part.

What does %a, %c and %f mean in my example? Or what does %b mean in your example?
Or can you refer me to any link which explains that? I tried to google it, but couldn't find any source that explains it.

Last edited by Catball; 10-22-2022 at 05:18 PM.
 
Old 10-22-2022, 05:22 PM   #5
Catball
LQ Newbie
 
Registered: Oct 2022
Posts: 4

Original Poster
Rep: Reputation: 0
@michaelk
Thank you for your reply.

The code snippet is from this site.
 
Old 10-22-2022, 05:37 PM   #6
michaelk
Moderator
 
Registered: Aug 2002
Posts: 23,677

Rep: Reputation: 5184Reputation: 5184Reputation: 5184Reputation: 5184Reputation: 5184Reputation: 5184Reputation: 5184Reputation: 5184Reputation: 5184Reputation: 5184Reputation: 5184
That is scripting code (called macros) specific to vifm and not bash. They are variables but since I have not played with vifm I am not sure of their exact meaning.

https://vifm.info/manual.shtml
https://vifm.info/manual.shtml#Command%20macros

Last edited by michaelk; 10-22-2022 at 05:38 PM.
 
Old 10-22-2022, 06:01 PM   #7
Catball
LQ Newbie
 
Registered: Oct 2022
Posts: 4

Original Poster
Rep: Reputation: 0
@michaelk

Thank you very much. The syntax confused me, as it looked similar to bash.
Thank you also for the links, I will take a look at them.

Last edited by Catball; 10-22-2022 at 06:02 PM.
 
Old 10-23-2022, 03:22 AM   #8
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,958

Rep: Reputation: 3173Reputation: 3173Reputation: 3173Reputation: 3173Reputation: 3173Reputation: 3173Reputation: 3173Reputation: 3173Reputation: 3173Reputation: 3173Reputation: 3173
@Catball - to mark the thread as SOLVED, please use the link under Thread Tools
 
  


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
what does "let" mean in bash? turf Programming 2 08-11-2010 03:04 PM
Bash script - what does this variable mean? ${1##*/} purecharger Linux - General 7 11-11-2009 05:11 AM
What does a single period ( . ) mean in bash? BobTheSlob Programming 10 08-18-2007 03:00 AM
Bash - what does if [ ${?} -ne 0 ] mean? davee Linux - Newbie 4 09-14-2005 08:57 AM
bash script, line1 #!/bin/sh - what does it mean? ombill Linux - Newbie 5 07-05-2004 12:38 PM

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

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