This question already has answers here:
Renaming multiples files with a bash loop
(3 answers)
Closed 8 years ago.
I have a directory, let's say its name is direct in which has multiple files whose names are .xyz, .abc, .klm and .etk4 etc. Is there a way to make all those hidden files visible at the same time instead of one by one? I know this question has been asked before here but I did not get the answer. I hope somebody can explain it to me in a simple way since I am not much familiar with linux.
for file in .[^.]*
do
mv "${file}" "${file#.}"
done
${var#prefix} expands to the value of $var with the initial prefix removed.
Related
This question already has answers here:
Globbing certain YYYYMMDD dates
(2 answers)
Closed 3 years ago.
I'm trying to delete specific folders in a sub-directory. For example, I have a directory where output of a specific result from something else collects, like:
Jobs/Market/Java
In that directory, I'll have outputs like these with dates and some random numbers in the end:
OUTPUT_201908809_134243
OUTPUT_201908810_242323
OUTPUT_201908811_152342
OUTPUT_201908815_124243
I'm trying to run a job that deletes folders that have '201908809'-'201908811' and leaves the remaining ones.
I've tried to manually deleting them using rm -r and the folder name. I know there has to be an easier way. I've looked up some things on stack and found lines that only delete folders that have an starting or and ending of the folder name.
What's the standard way of accomplishing this with Bash?
You can use wildcards for rm for example in this case you can use rm -rf *_201908809_* * means match all characters
https://www.shell-tips.com/2006/11/04/using-bash-wildcards/
This question already has answers here:
Get list of open files (descriptors) in OS X
(9 answers)
Closed 5 years ago.
In terminal how do I output which files a process is calling upon? For instance, if I was using Adobe Premiere and I wanted show which project file Premiere had open via terminal.
Not sure what you mean by calling upon. If you are looking for all the files currently opened by your process, use lsof:
lsof -p PID
where PID is the ID of the process you are looking at.
This question already has answers here:
Working with huge files in VIM
(10 answers)
How to edit multi-gigabyte text files? Vim doesn't work =( [closed]
(15 answers)
Closed 6 years ago.
I have a db dump file that is over 5 gigs in size and I'm looking to do a quick edit to the create database and use database command. This dump is provided to me.
I've been using vim to do this from the command line, but it takes a while to load. I'm able to use less to read very quickly. Is there a way to edit the file without having to wait several minutes for the full file to load in vim? This can be a param passed to vim, or different common way to edit files from command line.
I'm looking for a general solution that I can apply to other large files too, so would like a linux command that would allow me to edit the top of the file quickly.
You can use cat:
cat file_with_create_cmd db_dump > new_dump
If you want to use that in a subsequent command instead of writing it to a file, you may use process substitution:
process_dump <(cat file_with_create_cmd db_dump)
This question already has answers here:
Get current directory or folder name (without the full path)
(24 answers)
Closed 7 years ago.
So long story short I have to make a Shell Script where I need to have something like two variables, the first one contains a path read from the keyboard (something like:this/is/the/path/I/need)
I really need to extract the last folder of that path example, and put it in another variable, in my example I need to get out of the path the "need" part and put it in the second variable. How can I do this? The fact that this is read from the keyboard makes it pretty hard to do in my opinion. Thanks!
$ read path
this/is/the/path/I/need
$ directory=$(basename $path)
$ echo $directory
need
$
This question already has answers here:
How do I remove the file suffix and path portion from a path string in Bash?
(15 answers)
Closed 7 years ago.
Here's where I'm stuck up.
I've a old file (Fieldart_1.2.war). And I've a new file named Fieldart_1.4.war.
I just have to deploy the new one. But, before that I need to make sure I'm hitting the right file.
Is there anyway I can compare just the first part of the two files i.e., 'Fieldart' ? like, if the first part matches, go ahead with the deployment otherwise, throw an error..
What do you guys think ?
use the command find . -name "Fieldart*"