Hello so I've stored some csv data to be read into variables like this
Code:
When using the mkdir command to make the directories based on $dirname it works perfectly and i get all directories made based on each name, however when trying to Echo text into a file called starter.txt it gives me an error says the file or name doesn't exist. I'm trying to get it to generate ths file for every user. This is the full error
this lists this error 20 times because of 20 users and 20 differnty names however is finding directory but not making file?
please help.
Moderator's Comments:
As per forum rules, please use tags.
Last edited by RavinderSingh13; 11-28-2019 at 09:36 PM..
Alrigt, I need to write a shell script where it counts the number of folders and files and dispays "My home directory has 'x' files and 'y' directories."
So, I was thinking of doing this.
set x = `ls | wc`
so, if I have 8 files and folders in my home directory, x is not 8.
now, I was... (1 Reply)
Anyone know where I can get started in C++ programming in unix?
Any good free tutorials or websites to start at?
I am okay in unix scripting but have never done c programming of any sort...
What are the main advantages of using C++ ? (2 Replies)
Hey Guys,
I am creating a bash script on my freeBSD box, the script should basically ask the user to enter a username and domain. The script will take this information and basically append alot of information to config files so the user can receive email from that domain and create a web site at... (1 Reply)
Hello,
I am trying to write a script that reads names from a file called input, removes names if they have the same letter next to each other and prints the others.
e.g. Colin & John would be printed
Garry & Lynn would be removed
My thinking is that I read in each name and... (3 Replies)
Hi, I'm a beginner at shell scripting, just started scripting in bash a few days ago.
I want to test if the command ls *.jpg returns exit code 2, and if yes I want to execute a new command ls *.jpeg, doing a test on it... and pretty much repeat the procedure.
Is this correct?
#!/bin/bash... (1 Reply)
Hi All,
I have a script that I wrote on a bash shell, I use it to sort files from a directory into various other directories. I have an variable set, which is an array of strings, I then check each file against the array and if it is in there the script sorts it into the correct folder.
But... (5 Replies)
Hello,
I am new to Linux and studying to become a Unix System Admin. I am taking a course in which I was practicing creating a bash script to ping a particular IP address. The script can be found below:
#/bin/bash
echo "Enter the IP address"
read ip
if
then
ping -c 1 $ip
if ;... (3 Replies)
Hi everyone,
i have the following script.sh:
foo='lsusb | grep Webcam | cut -c16-18'
sudo /home/user/public/usbreset /dev/bus/usb/001/$foo
when i try to call this script from python using subprocess.call("script.sh", shell=True) it seems that only 'sudo /home/user/public/usbreset' is being... (6 Replies)
I at the moment, making a simple bash script, capable of setting up an workspace for me, so i don't have to do it manually.. Problem is though i can't seem to provide the bash script any argument, without running into my error checks, checking for input...
Here is the code:
#!/bin/bash... (7 Replies)
Hi everyone, first time visitor to these forums here.
Keeping a long story short I've been attempting to learn how to code in bash. I have VERY little previous experience with coding languages besides simply copying and pasting batch scripts for Windows. So, with that in mind I've followed a... (4 Replies)
Discussion started by: Meta
4 Replies
LEARN ABOUT OSX
dirname
DIRNAME(3) BSD Library Functions Manual DIRNAME(3)NAME
dirname -- extract the directory part of a pathname
SYNOPSIS
#include <libgen.h>
char *
dirname(char *path);
DESCRIPTION
The dirname() function is the converse of basename(3); it returns a pointer to the parent directory of the pathname pointed to by path. Any
trailing '/' characters are not counted as part of the directory name. If path is a null pointer, the empty string, or contains no '/' char-
acters, dirname() returns a pointer to the string ".", signifying the current directory.
IMPLEMENTATION NOTES
The dirname() function returns a pointer to internal storage space allocated on the first call that will be overwritten by subsequent calls.
Other vendor implementations of dirname() may modify the contents of the string passed to dirname(); if portability is desired, this should
be taken into account when writing code which calls this function.
LEGACY SYNOPSIS
#include <libgen.h>
char *
dirname(const char *path);
In legacy mode, path will not be changed.
RETURN VALUES
On successful completion, dirname() returns a pointer to the parent directory of path.
If dirname() fails, a null pointer is returned and the global variable errno is set to indicate the error.
ERRORS
The following error codes may be set in errno:
[ENAMETOOLONG] The path component to be returned was larger than MAXPATHLEN.
SEE ALSO basename(1), dirname(1), basename(3), compat(5)STANDARDS
The dirname() function conforms to X/Open Portability Guide Issue 4, Version 2 (``XPG4.2'').
HISTORY
The dirname() function first appeared in OpenBSD 2.2 and FreeBSD 4.2.
AUTHORS
Todd C. Miller
BSD October 12, 2006 BSD