Part 3: Working with Files and Directories
Welcome back to our “Mastering Bash Scripting for Embedded Linux Development“ series! In this third part, we’ll explore essential techniques for working with files and directories in Bash scripting. From file manipulation to directory traversal and pattern matching, mastering these concepts will empower you to efficiently manage and manipulate data within your embedded Linux systems.

File Manipulation
Bash scripting provides powerful tools for manipulating files, including creating, reading, writing, and deleting them.
Creating a File
Use the touch a
command followed by the filename to create an empty file. For example,
# Create a new file
touch new_file.txt

Besides touch
, you can also use redirection with echo
to create files with content. For instance:

Reading from a File:
The cat
command is handy for displaying the contents of a file directly in the terminal. For example,
# Read the contents of a file
cat greeting.txt

Apart from cat
, you can use head
or tail
to display the beginning or end of a file, respectively. For example:
head greeting.txt

Note: When using the head
command, by default, it prints the first 10 lines of a file. Similarly, the tail
command prints the last 10 lines of a file by default. However, if the file contains fewer than 10 lines, head
or tail
will print all the lines available in the file. For example, executing tail greeting.txt
will print the last 10 lines of the greeting.txt
file if it contains 10 or more lines. If the file contains fewer than 10 lines, tail
will print all of them.
Writing to a File
You can use redirection (>
or >>
) to write to a file. For example,
# Write to a file
echo "Hello, world!" > greeting.txt

Append content to a file using >>
. For example, to add more text to greeting.txt
:
# Append to a file
echo "Welcome to Embed Threads" >> greeting.txt

Deleting a File
The rm
command followed by the filename removes a file. Be cautious when using rm
as it deletes files permanently without confirmation. For example,
# Delete a file
rm greeting.txt

Note: Use wildcards with rm
to delete multiple files. For instance, to remove all .txt
files in the current directory: rm *.txt
Directory Traversal
Navigating directories and accessing files within them is a common task in Bash scripting. You can use commands like cd
, ls
, and pwd
to traverse directories and perform operations on files.
Changing Directories
Use the cd
command followed by the directory name to change your current working directory. For example,
# Change directory
cd /path/to/directory
Listing Contents
The ls
command lists the contents of a directory. Adding options such as -l
provides detailed information about files, including permissions and ownership.
# List files in the current directory
ls
# Print the current directory
pwd

cd ~
: Changes the current directory back to the user’s home directory (/home/alok
).cd "Embed Threads"
: Changes the current directory to a directory namedEmbed Threads
. However, note that the directory name contains a space, so it should be enclosed in quotes to be interpreted as a single argument.cd ..
: Moves up one directory from/home/alok/Embed Threads
to/home/alok
.cd documents
: Attempts to change the directory to a directory nameddocuments
. However, it results in an error messagebash: cd: documents: No such file or directory
because there is no directory nameddocuments
in the current directory (/home/alok
).
Moving Files
You can move files between directories using mv
. For instance, to move file.txt
from the current directory to Documents
:
mv file.txt Documents/
Copying Files
Similarly, copy files with cp
. For example, to copy file.txt
to a backup folder:
cp file.txt backup/
File Permissions and Ownership
Understanding file permissions and ownership is crucial for securing your files and controlling access. In Linux systems, each file has permissions for the owner, group, and others, denoted by read (r
), write (w
), and execute (x
).
- Viewing Permissions: Utilize the
ls -l
command to view permissions. Permissions are displayed as a sequence of characters, such as-rwxr-xr--
, where the first three characters represent permissions for the owner, the next three for the group, and the last three for others. - Changing Permissions: The
chmod
command allows you to change file permissions. Syntax:chmod [permissions] filename
. For instance,chmod +x script.sh
adds execute permissions toscript.sh
. - Ownership: The
chown
command changes the ownership of files. Syntax:chown [user]:[group] filename
. For example,chown user:group example.txt
changes the ownership ofexample.txt
.

The string -rwxr-xr-x 1 root root 0 Mar 24 13:18 script.sh
represents the file permissions and metadata associated with the file named script.sh
. Let’s break down each part of this string:
- Permissions: The first part of the string
-rwxr-xr-x
indicates the permissions of the file. Each character represents the permissions for the file’s owner, the group the file belongs to, and others (users who are not the owner and not in the group). The characters have the following meanings:-
indicates that the corresponding permission is not granted.r
indicates read permission.w
indicates write permission.x
indicates execute permission.
rwx
indicates that the owner of the file (root
) has read, write, and execute permissions.r-x
indicates that the group (root
) has read and execute permissions but not write permissions.r-x
indicates that others (users who are not the owner and not in the group) have read and execute permissions but not write permissions.
- Number of Hard Links: The number
1
after the permissions indicates the number of hard links to the file. Hard links are additional names for the same file on the file system. In this case, there is only one hard link to the file. - Owner and Group: The next two entries
root root
indicate the owner and group of the file. In this case, the owner isroot
and the group is alsoroot
. - File Size: The number
0
indicates the size of the file in bytes. In this case, the file size is0
, meaning the file is empty. - Date and Time:
Mar 24 13:18
represents the date and time when the file was last modified or created. In this case, the file was modified or created on March 24th at 13:18 (1:18 PM). - Filename: Finally,
script.sh
is the name of the file.
The above explanation illustrates symbolic notation, but you can also utilize octal numbers with the chmod
command.
- Read (r) is represented by the value 4.
- Write (w) is represented by the value 2.
- Execute (x) is represented by the value 1.
- No permission (-) is represented by the value 0.
To determine the octal value of a set of permissions, you simply add up the values for each permission. For example:
- If a file has read, write, and execute permissions for the owner, the octal value for the owner’s permissions would be 4 (read) + 2 (write) + 1 (execute) = 7.
- If a file has only read and execute permissions for the group, the octal value for the group’s permissions would be 4 (read) + 0 (no write) + 1 (execute) = 5.
- If a file has only read permission for others, the octal value for others’ permissions would be 4 (read) + 0 (no write) + 0 (no execute) = 4.
So, in octal notation, the file permissions -rwxr-xr-x
would be represented as 755
:
- Owner: Read (4) + Write (2) + Execute (1) = 7
- Group: Read (4) + Execute (1) = 5
- Others: Read (4) + Execute (1) = 5
To modify file permissions using octal notation, you would use the chmod
command followed by the octal representation of the desired permissions. For example:
# Change file permissions
chmod 755 script.sh
Bash Scripting
Example 1: Create 10 Files with Random String
#!/bin/bash
# This script creates 10 files with random strings as their content
# Define files to create
files=("file1.txt" "file2.txt" "file3.txt" "file4.txt" "file5.txt"
"file6.txt" "file7.txt" "file8.txt" "file9.txt" "file10.txt")
# Create files with random content
for file in "${files[@]}"; do
# Generate a random string
random_string=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)
echo "$random_string" > "$file"
done
echo "Files created successfully!"

Example 2: Automated File Backup Script
#!/bin/bash
# This script creates a backup of specified files
# Define files to backup
files="file1.txt file2.txt"
# Create a backup directory if it doesn't exist
backup_dir="backup"
if [ ! -d "$backup_dir" ]; then
mkdir "$backup_dir"
fi
# Copy files to the backup directory
for file in $files; do
cp "$file" "$backup_dir/"
done
echo "Backup completed successfully!"

Example 3: File Permission Checker
#!/bin/bash
# This script checks the permissions of a file
# Define file to check
file="file1.txt"
# Check file permissions
permissions=$(ls -l "$file" | cut -d ' ' -f 1)
echo "Permissions of $file: $permissions"

File Globbing and Pattern Matching
Bash provides powerful mechanisms for matching filenames using patterns:
Wildcard Characters
Use wildcard characters such as *
(matches any string) and ?
(matches any single character) for pattern matching. For example, ls *.txt
lists all files with a .txt
extension.
# List all files with a .txt extension
ls *.txt
# Delete all files starting with "temp"
rm temp*
Brace Expansion
Brace expansion allows you to generate arbitrary strings. For example, echo file{1..3}.txt
will display file1.txt
, file2.txt
, and file3.txt
.
cat file{1..3}.txt

Character Classes
Match files with specific characters. For instance, to list files with numbers in the name:
ls *[0-9]*

Bash Scripting
Example 4: Pattern Matching Script
#!/bin/bash
# This script lists all text files in the current directory
# List text files
echo "Text files:"
ls *.txt

Example 5: File Cleanup Script
#!/bin/bash
# This script deletes all text files in the current directory
# Delete all text files
find . -name "*.txt" -type f -delete
echo "Text files deleted successfully!"

In this part of our series, we’ve explored essential techniques for working with files and directories in Bash scripting. From file manipulation to directory traversal and pattern matching, these concepts are foundational for managing data within your embedded Linux systems.
FAQ
Q: Can I create a file and a directory with the same name?
A: No, a file and a directory cannot share the same name in the same location. However, they can have the same name if they are in different locations.
Q: How can I view the contents of a file without using cat
, less
, or more
?
A: You can use the head
command to display the first part of a file, or the tail
command to display the last part of a file.
Q: What is the difference between >
and >>
?
A: The >
operator overwrites the file with the output of the command, while the >>
operator appends the output to the end of the file.
Q: How can I delete a directory that is not empty?
A: You can use the rm -r
command to remove a directory and its contents. Be careful with this command, as it will delete the directory and all of its contents without asking for confirmation.
For more detailed information, you can always refer to the official GNU Bash documentation.
That’s all for today’s post.
Stay curious, keep exploring, and happy scripting!
This concludes Part 3 of our series. Stay tuned for future installments!
Growth components are extra essential for power and muscle mass in girls than in men. Since women have simply as a lot IGF-1
as women and men produce ~3 instances as much growth hormone
as men, this explains partly why having much less testosterone doesn’t limit how much muscle they will construct.
To make issues extra advanced, the sex hormones and development components work together and
all these hormones additionally work together along with your
genes.
Begin with low doses, pay close consideration to how your physique reacts, and don’t ignore any warning signs.
For ladies, the dangers can typically feel like they outweigh the rewards,
so each selection should align together with your health and long-term objectives.
Steroids are highly effective for lean muscle positive aspects,
however they come with risks that should never be
overlooked. Steroids, scientifically often identified as anabolic-androgenic steroids (AAS), are artificial derivatives of the male
sex hormone testosterone. They are designed to mimic the
effects of testosterone within the body, selling muscle development, enhancing athletic performance, and enhancing restoration instances between workouts.
Steroids are identified for their ability to extend muscle mass by
enhancing protein synthesis and nitrogen retention.
Thus, generally used compounds like Testosterone, Dianabol, and Trenbolone are not recommended for female use.
Whereas these steroids may not cause long-term physical health
points for ladies, the risk of virilization and its potential impact on psychological well-being in the long
run makes them unfavorable decisions. In our expertise,
Primobolan (methenolone) is probably considered one
of the greatest steroid cycles for females as a outcome of its mild nature.
It sometimes produces few unwanted aspect effects
however noteworthy modifications in body composition. Anavar causes reductions
in HDL ldl cholesterol, probably inflicting hypertension (high blood pressure) and increasing the risk of arteriosclerosis.
Nevertheless, in our lipid profile testing, Anavar solely causes delicate
cardiovascular strain in comparison with other anabolic steroids.
Due to decrease fan and media involvement, natural bodybuilding
pays less.
The analysis started with listening and studying the interviews in their entirety
with an open thoughts to facilitate an initial
understanding. After repeated studying, the transcript was divided
into meaning models to seek for meanings. From a phenomenological perspective and validity analysis should be meaning-oriented (van Wijngaarden et al., 2017).
When the interviews were emptied of all that means, the meanings were clustered collectively to seek out similarities and differences.
A sample of meanings slowly emerged and formed a meaningful construction that constitutes the essence of the phenomenon.
The aim is then to explain the variations and nuances of
the phenomenon, which means the constituents. This implies that the focus continues to be
on the phenomenon, however the nuances are illustrated with quotes from the informants.
Long-term use of those steroids can result in liver injury or dysfunction.
Ladies ought to opt for injectable steroids or those with a lower toxicity degree to
reduce this danger. Common liver perform exams are also recommended during a
steroid cycle.
These are just some things to look for, and it takes time and
experience to identify who is natural and who isn’t.
If it’s any consolation, you’ll solely ever have the power to say who is on steroids, as lots of the most prolific users (like long-distance cyclists) aren’t visibly in gear.
Steroids lead to excessive physique hair because of
hormones referred to as androgens. You should check the foundations and
guarantee your medicines or drugs, if any, are free of these substances.
Testosterone is an aggressive hormone and as with males, when women take testosterone they become more aggressive and prone
to robust emotions corresponding to exaggerated anger that
can lead to violence. Some women would possibly
develop neurological complications corresponding to hand and physique shaking as seen in folks with
Parkinson’s illness. Even within the much less muscular divisions,
many women are more and more turning to PED’s for an advantage.
Although it could appear silly to assume of bikini competitors
using steroids, I can guarantee you that not only does it happen,
however it occurs with regularity. This is not to recommend that each one bikini ladies use these drugs, as that definitely isn’t the case, but
the point right here is that if they’re being used in bikini, they’re getting used everywhere.
Whereas the Internet is actually a useful information useful resource, one must be able to separate the wheat from
the chaff so as to use it effectively.
Pairing it with calcium and vitamin D enhances its benefits for bone well
being, making it a triple threat for long-term well-being.
Goal for a minimal of 30 grams of protein at each meal to hold up lean mass and
optimize recovery. The higher the dosage and the longer the cycle, the upper the risk of unwanted side effects.
In our experience, profitable Anavar dosages for ladies vary from 5 to 10 mg/day.
We have had success in accelerating over the counter steroid (Geri) restoration of women’s endogenous testosterone when supplementing with DHEA, the official prescription medication for women with low androgen ranges.
Anavar suppresses endogenous testosterone, which isn’t simply problematic for males; testosterone remains an important hormone
for ladies as nicely. However, one of the best benefits of Anavar
is that it burns both visceral and subcutaneous fat, serving to ladies
achieve a smaller waist.
70918248
References:
stackers pills high, http://freeok.cn/home.php?mod=space&uid=7335920,
Every one works differently on the body, and each has its own potential side effects.
It is important to know what does Anabolic steroids do kind of
treatment you’re giving your canine and to recognize
the indicators of potential problems the drug may cause. Anabolic or “muscle-building” steroids are
artificial variations of testosterone, the male intercourse hormone.
Abusers inject or ingest steroids or apply lotions and gels at dosages that are up to one hundred occasions greater than therapeutic ranges.
Anabolic effects also embrace increased production of red blood cells.
Mineralocorticoids are responsible for maintaining the stability of
water and electrolytes within the physique while glucocorticoids play a role within the stress response.
When canine have Addison’s disease, their
adrenal glands do not produce enough of either of those two forms
of steroids – mineralocorticoids and glucocorticoids. Remedy for Addison’s illness entails day by day doses of a glucocorticoid, usually prednisone, and month-to-month injections of a mineralocorticoid, desoxycorticosterone (Percortin-V, Zycortal).
Because corticosteroids ease swelling and irritation, docs usually prescribe them to
treat circumstances like bronchial asthma, hives, or lupus.
Corticosteroids can provide substantial aid of signs, however include the risk of great unwanted effects, particularly if used long run.
One fingertip unit is the quantity of medicine distributed from the tip of the
index finger to the crease of the distal interphalangeal joint and covers roughly 2% physique surface space on an grownup.
Topical corticosteroids are applied a few times per
day for up to three weeks for super-high-potency corticosteroids or as a lot as
12 weeks for high- or medium-potency corticosteroids.
There is no specified time limit for low-potency topical corticosteroid use.
Some of the unwanted aspect effects of systemic corticosteroids
are swelling of the legs, hypertension, headache, simple bruising,
facial hair development, diabetes, cataracts, and puffiness of the
face. Glucocorticoids are the steroids most frequently prescribed by veterinarians for our canines.
Corticosteroids are a category of human-made or synthetic
medication utilized in nearly every medical specialty.
They decrease inflammation within the physique by lowering the manufacturing of sure chemical substances.
At greater doses, corticosteroids additionally cut back immune system
activity. In addition to bronchodilators, anti-inflammatory medicines, notably inhaled corticosteroids (ICS),
play a task in COPD management. While not typically beneficial as
a standalone treatment, ICS are sometimes prescribed
in combination therapy for these with average to extreme COPD.
A prescription for topical corticosteroids ought to include the medication name, focus,
formulation, directions for software, and amount. The selection of which agent,
concentration, and formulation to use depends on the condition being
handled, the location on the body, characteristics of the lesion, and patient components similar to age.
A brief course of oral steroids normally causes no side-effects.
Side-effects usually have a tendency to occur with a long course of oral steroids (more than 2-3 months), or
if quick programs are taken repeatedly. Typically the steroid remedy is gradually stopped if the situation improves,
and restarted if it worsens. The form mentioned in this leaflet
is the pill kind, taken by mouth, referred to as oral steroids.
As elite athletes are caught dishonest by utilizing anabolic steroids, perhaps their notion as positive function models
will fade and the usage of steroids decrease.
Increased stress to test athletes at younger ages
may decrease using steroids as nicely. However, so lengthy as adolescents perceive that anabolic steroids are required to compete
at sports activities, their use may continue in the foreseeable future.
This list just isn’t full and lots of different medication may have
an result on Decadron. Decadron is used to treat many various situations such as allergic issues, pores and skin situations,
ulcerative colitis, arthritis, lupus, psoriasis, or respiratory issues.
Corticosteroids are produced in the adrenal gland located above the kidney.
This medicine would possibly trigger thinning of the bones (osteoporosis)
or slow progress in kids if used for a really lengthy time.
Tell your physician if you have any bone pain or
if you have an elevated threat for osteoporosis.
If your baby is utilizing this medicine, tell the physician when you assume your youngster is not growing correctly.
Though sure medicines should not be used collectively in any respect, in other instances two different medicines may be used together even when an interaction would
possibly occur.
High blood sugar can cause fatigue, thirst, and frequent urination amongst different symptoms.
Corticosteroids also can interfere with many other
bodily processes, from your bones to your blood strain. Not everyone will develop side effects from
taking corticosteroids. Aspect effects are more
probably if corticosteroids are taken at a high dose over a protracted time period.
Tezepelumab-ekko (Tezspire) is a just lately FDA-approved biologic for folks with severe bronchial asthma.
This will vary relying on the steroid used and the condition for which they’re prescribed.
For short programs, usually a relatively high dose is prescribed each day for as much as every week, after which stopped abruptly at the
end of the course. If oral steroids are taken for longer than this it is essential to
reduce the dose steadily before stopping. Steroid medicines
(sometimes referred to as corticosteroids) are
man-made (synthetic) variations of steroid hormones produced by the body.