Glam Prestige Journal

Bright entertainment trends with youth appeal.

I am very new to the linux , i am trying to make a directories from the files which is present in the current working directory, one directory is created but another one is not creating it's throwing an error likemkdir: missing operand

for files in *.txt
do
folderName= echo $files | awk -F. '{print $1}';
mkdir $folderName;
done
3

1 Answer

If you need the output of a command as a new variable, put the command between $(). Like this:

folderName=$(echo $files|awk -F. '{print $1} ';)

To see what you're doing, add another echo command to confirm that the folder name has been correctly constructed:

echo $folderName

before you do the mkdir.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy