I need empty .txt files and wanted to know if there is any possibility to do it in the terminal on a mac?
the empty txt files should be named by numbers from 1 to 200, like 1.txt,2.txt,3.txt...200.txt
thanks in advance
run on terminal
for i in {1..200}; do echo > ${i}.txt; done
Related
I have a text file that has a list of filenames.Now I want to see if these files are present in a specific folder using bash script. I have no experience in writing bash scripts.So please help me with this
a simple for loop can do what you need :
for file in $(cat yourfilelist.txt); do ls -l /folder/to/check/"$file"; done
for missing files you'd get No such file or directory
I am trying to download files of type *.bat and *.txt using WinSCP get command and put it in D:\example folder as shown below:
get /zjpw/*.* D:\example\
By above line I am getting all different type of files, but I want to get only .bat and .txt files. How do I achieve that?
Thanks in advance.
To download .bat and .txt files from /zjpw folder only:
get /zjpw/*.bat /zjpw/*.txt D:\example\
To download files even from subfolders:
get /zjpw/* D:\example\ -filemask=*.bat;*.txt
See https://winscp.net/eng/docs/scriptcommand_get
I have to do some things in some files from a directory in solaris. In that directory, I have thousands of files. Some of them, begin with FAC_. I need to make an array variable with those names of files (which four first letters name are FAC_), and then go over the array to do some task to each file.
How can I accomplish that?
Thanks
I think the simplest approach would be something like this:
files="FAC_*"
for file in $files; do
echo "$file"
done
If the files aren't in the same directory as the script you can use the following line to retrieve them.
files="$path/FAC_*"
I need to make an array containing over 100 different image names and I wonder if there is any way to "convert" the image names from a folder into a .txt file using terminal to then paste them into xcode instead of manually write all of them. Any advice?
You can go to terminal and type
ls # list files
ls -lt # list files with details
ls *.jpg # list only jpg files
ls > files.txt # list files and write them to files.txt
The # by the way, is just a comment. You can combine the above commands.
Although I need to say, that the PROPER way of doing this, is letting you code find those files in the desired directory, unless there's a good reason for not doing so.
I have a text file fold.txt that contains one line fold_nam:
$ cat fold.txt
fold_nam
This name in the the text file is an output that was created during a program run of a folder's name that now contains other files that I need to work with.
I am writing a big script and now I need to enter this folder and I need to get the name from the text file. I tried several things but cannot really work it out.
There's no need to use cat:
cd $(<fold.txt)
If you want to read the line into a variable: read -r folder_name < fold.txt
You should be able to do this:
cd $(cat fold.txt)
or
cd `cat fold.txt`