Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 8 years ago.
Improve this question
When I run ls -lrt command on a Unix folder , I get the following output
MyServer> ls -lrt
total 10
drwxr-x--- 3 UnixUser other 512 Jul 22 2011 FolderA
lrwxrwxrwx 1 UnixUser other 46 Aug 23 2011 BEA -> ../../../Some/Folder/SOLARIS/BEA
I am not sure what is BEA in these folders. They do not seem to be files nor folders. Why is there a arrow besides them pointing to somewhere else?
BEA and Perlx.x in these folders are symbolic links. The symbolic link is another name that "points to" the real file.
The option -l tells the command to use a long list format. It gives back several columns wich correspond to:
Permissions
Number of hardlinks
File owner
File group
File size
Modification time
Filename
The first letter in the permissions (lrwxrwxrwx) column show the file's type. l here means a link, A d means a directory and a - means a normal file (there are other characters, but those are the basic ones). The next nine characters are divided into 3 groups, each one a permission. Each letter in a group correspond to the read, write and execute permission, and each group correspond to the owner of the file, the group of the file and then for everyone else.
[ File type ][ Owner permissions ][ Group permissions ][ Everyone permissions ]
The characters can be one of four options:
r = read permission
w = write permission
x = execute permission
- = no permission
Finally, the + at the end means some extended permissions.
These are called symbolic links in linux (shortcuts in windows)
When you work on them, for eg vim BEA , you will be editing the actual file in ../../../Some/Folder/SOLARIS/BEA
The file in question is a symbolic link. The symbolic link is another name that "points to" the real file.
When you do ls -l it also shows you which file is pointed to by the link. You can actually see:
lrwxrwxrwx
^
|________ `l` here means a link
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 1 year ago.
Improve this question
I am trying to construct and submit an array job based on R in the HPC of my university.
I'm used to submit array jobs based on Matlab and I have some doubts on how to translate the overall procedure to R. Let me report a very simple Matlab example and then my questions.
The code is based on 3 files:
"main" which does some preliminary operations.
"subf" which should be run by each task and uses some matrices created by "main".
a bash file which I qsub in the terminal.
1. main:
clear
%% Do all the operations that are common across tasks
% Here, as an example, I create
% 1) a matrix A that I will sum to the output of each task
% 2) a matrix grid; each task will use some rows of the matrix grid
m=1000;
A=rand(m,m);
grid=rand(m,m);
%% Tasks
tasks=10; %number of tasks
jobs=round(size(grid,1)/tasks); %I split the number of rows of the matrix grid among the tasks
2. subf:
%% Set task ID
idtemp=str2double(getenv('SGE_TASK_ID'));
%% Select local grid
if idtemp<tasks
grid_local= grid(jobs*(idtemp-1)+1: idtemp*jobs,:);
else
grid_local= grid(jobs*(idtemp-1)+1: end,:); %for the last task, we should take all the rows of grid that have been left
end
sg_local=size(grid_local,1);
%% Do the task
output=zeros(sg_local,1);
for g=1:sg_local
output(g,:)=sum(sum(A+repmat(grid_local(g,:),m,1)));
end
%% Save output by keeping track of task ID
filename = sprintf('output.%d.mat', ID);
save(filename,'output')
3. bash
#$ -S /bin/bash
#$ -l h_vmem=6G
#$ -l tmem=6G
#$ -l h_rt=480:0:0
#$ -cwd
#$ -j y
#Run 10 tasks where each task has a different $SGE_TASK_ID ranging from 1 to 10
#$ -t 1-10
#$ -N Example
date
hostname
#Output the Task ID
echo "Task ID is $SGE_TASK_ID"
export PATH=/xx/xx/matlab/bin:$PATH
matlab -nodisplay -nodesktop -nojvm -nosplash -r "main; ID = $SGE_TASK_ID; subf; exit"
These are my questions:
Suppose I'm able to translate "main" and "subf" into R language. Should I be extra-careful about anything in particular concerning the parallelisation? For example, do I have to declare some parallel environment, such as parLapply or dopar?
In the "main" file I should also install some R packages. Can I do them locally in my folder directly at the beginning of the "main" file, or should I contact the HPC administrator to install them globally?
I could not find any example of bash file for R in the instructions given by my university. Therefore, I have doubts on how to re-adapt the above bash file. I suppose that the only lines to change are:
export PATH=/xx/xx/matlab/bin:$PATH
matlab -nodisplay -nodesktop -nojvm -nosplash -r "main; ID = $SGE_TASK_ID; subf; exit"
Could you give some hints on how I should change them?
The parallelization is handled by the HPC, right? In which case, I think "no", nothing special required.
It depends on how they allow/enable R. In a HPC that I use (not your school), the individual nodes do not have direct internet access, so it would require special care; this might be the exception, I don't know.
Recommendation: if there is a shared filesystem that both you and all of the nodes can access, then create an R "library" there that contains the installed packages you need, then use .libPaths(...) in your R scripts here to add that to the search path for packages. The only gotcha to this might be if there are non-R shared library (e.g., .dll, .so, .a) requirements. For this, either "docker" or "ask admins".
If you don't have a shared filesystem, then you might ask the cluster admins if they use/prefer docker images (you might provide an image or a DOCKERFILE to create one) or if they have preferred mechanisms for enabling various packages.
I do not recommend asking them to install the packages, for two reasons: First, think about them needing to do this with every person who has a job to run, for any number of programming languages, and then realize that they may have no idea how to do it for that language. Second, package versions are very important, and you asking them to install a package may install either a too-new package or overwrite an older version that somebody else is relying on. (See packrat and renv for discussions on reproducible environments.)
Bottom line, the use of a path you control (and using .libPaths) enables you to have complete control over package versions. If you have not been bitten by unintended consequences of newer-versioned packages, just wait ... congratulations, you've been lucky.
I suggest you can add source("main.R") to the beginning of subf.R, which would make your bash file perhaps as simple as
export PATH=/usr/local/R-4.x.x/bin:$PATH
Rscript /path/to/subf.R
(Noting that you'll need to reference Sys.getenv("SGE_TASK_ID") somewhere in subf.R.)
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 12 months ago.
Improve this question
I am using vi editor for UNIX. Sometimes I am experiencing an issue with getting out of vi editor, where I go to press esc then type ":wq" or "q!" to quit, but it is not escaping. vi editor just enters weird symbols/characters and I can't get out. What do I do to escape and exit when esc won't escape?
There are few more commands for that apart from the one you are using
Shift+zz to save (if modified )and exit
:cq quit without writing
EDIT :
I found some more commands that I just learned .
There are many ways to exit from vi editors, and you can use some of these commands to exit from other editors
Press F2, this will drop you in Insert Mode, now press: q and hit enter
another way is to press Ctrl + c or ctrl + z command to exit the vi editor forcefully.
press ZZ (shift+z+z). it will save and exit.
Ctrl + [ will also work like escape key.
the 3rd , and 6th command may or may not work on every system, as it depends on terminal's setting and system itself.
or you can do map certain keys to behave like escape, please refer this post , that will save you some keystrokes.
For me this worked:
CTL + c (this is equal to ESC in your case)
:wq! (to write save and quit) and then click enter
have you tried ESC then "ZZ"?
seems to work as a last result for me.
This can happen when vi is started with TERM=linux. You can use the set term command to solve this problem.
Set the TERM to vt100 with one of the following commands depending on the shell.
csh or tcsh: setenv TERM vt100
sh: TERM=vt100; export TERM
ksh, bash, or zsh: export TERM=vt100
vi should work without setting the terminal in kx mode(refer to this for a similar issue: https://unix.stackexchange.com/questions/86742/term-linuxxterm-vi-in-an-xterm-or-the-aaabbbbbbccddd-problem).
In order to save this, add the set TERM command to ~/.vimrc file so the option is loaded when starting vi.
Have you tried ^z followed by "kill" the process?
I just had this issue with editor of command line of Git Bash and what worked was press Esc and then :q!. When I typed only q!, it did not work.
press the following shift + esc
look at bottom left corner
write the following colon included :wq
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 years ago.
Improve this question
I want to access a text file and read some of its contents to change them with a new value.
This Find and Replace is really helpful but my requirement is slightly different.
Say if these are my file contents
image.description=Template Image 08182015
image.version=1.3.111
baseline.name=001_08_18_2015
I want to change them to
image.description=Template Image 08192015 #19 instead of 18
image.version=1.3.112 #112 instead of 111
baseline.name=001_08_19_2015 #19 instead of 18
At any point of time I will not be knowing what is the value of each variable but all I know is the variable name like "Image version" So now I need some script to find what is the value of variable image.version and auto increment the value to the next possible integer.
Any suggestions/ thoughts?
With GNU awk for the 3rd arg to match():
$ awk 'match($0,/(image\.version.*\.)(.*)/,a){$0=a[1] a[2]+1} 1' file
image.description=Template Image 08182015
image.version=1.3.112
baseline.name=001_08_18_2015
For the others since no arithmetic is involved you should be able to just use gensub() similarly.
Or, maybe this is the kind of thing you're looking for:
$ cat tst.awk
BEGIN { FS=OFS="=" }
$1=="image.description" { match($2,/.* ../); $2=substr($2,1,RLENGTH) substr($2,1+RLENGTH,2)+1 substr($2,3+RLENGTH) }
$1=="image.version" { match($2,/.*\./); $2=substr($2,1,RLENGTH) substr($2,1+RLENGTH)+1 }
$1=="baseline.name" { split($2,a,/_/); $2=a[1]"_"a[2]"_"a[3]+1"_"a[4] }
{ print }
$ awk -f tst.awk file
image.description=Template Image 08192015
image.version=1.3.112
baseline.name=001_08_19_2015
The following is from a school assignment.
The question asks
"What command enables you to find all empty files in your source
directory."
My answer; find -size 0 However, my instructor says that my answer is incorrect. The only hint (Regarding the entirety of the assignment) he gives me is "...minor errors such as missing a file name or outputting too much information" I was thinking, perhaps I should include the source directory within my find command.
I've been trying to figure this out for the past few hours. I've referenced my textbook and according to that I should be correct.
There's some other questions I'm having similar issues with. I've wracked my brain with this for hours. I just don't know. I don't understand what I'm doing wrong.
Since your assignment was to find all empty files in your source directory, the following command will do exactly what you want:
find . -size 0
Notice the dot (.) to tell the command to search in the current folder.
For other folders, you replace the "dot" with the folder you want.
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
I know I can do a "page down" using keyboard "spacebar" while browsing "man" command output on unix terminal window. Is there a corresponding keyboard shortcut for "page up"? To be generic, is there a list of keyboard shortcuts for man command? I did "man man" with no luck.
It depends on the pager that the man command uses on your system.
If it is less (as in 'less is more'), then you can go backwards. (With less, b goes back a page, amongst other options for doing that; so does Control-B. The h command gives me several pages full of options that I seldom or never use.)
If the pager is more (as in ... oh, there isn't an inverse jibe), then the answer may well be 'No, you cannot go backwards'.
On Mac OS X (10.7.4), the man man command cites the environment variables MANPAGER and HTMLPAGER that can be set; the default MANPAGER is less.
You can type h for help.
Type Ctrl-f and Ctrl-b to scroll down and up.
Ctrl-d and Ctrl-u will scroll half window.
Page Up = CTRL + B
Page Down = CTRL + F
C-v (aka Ctrl-v or ^V) and M-v (aka ESC-v, Alt-v or Meta-v) also work with less (to scroll down and up, respectively), for those familiar with Emacs keybindings.