How does one specify the permissions for files output by sbt? I need these to be set correctly in order to be able to test the code with my local Apache server.
In the scalaJS project after a clean fastOptJS I
can see that the launcherapp-fastopt.js files are user read only.
$ ls -al target/scala-2.13/
total 240
drwxr-xr-x 6 hjs staff 192 23 Oct 11:08 .
drwxr-xr-x 5 hjs staff 160 23 Oct 11:08 ..
drwxr-xr-x 6 hjs staff 192 23 Oct 11:08 classes
-rw------- 1 hjs staff 69861 23 Oct 11:08 launcherapp-fastopt.js
-rw------- 1 hjs staff 48380 23 Oct 11:08 launcherapp-fastopt.js.map
drwxr-xr-x 3 hjs staff 96 23 Oct 11:08 update
Apache won't see it with those permissions so I have to change the mode on the files like this:
$ chmod -R a+rX target/
$ ls -al target/scala-2.13/
total 240
drwxr-xr-x 6 hjs staff 192 23 Oct 11:08 .
drwxr-xr-x 5 hjs staff 160 23 Oct 11:08 ..
drwxr-xr-x 6 hjs staff 192 23 Oct 11:08 classes
-rw-r--r-- 1 hjs staff 69861 23 Oct 11:08 launcherapp-fastopt.js
-rw-r--r-- 1 hjs staff 48380 23 Oct 11:08 launcherapp-fastopt.js.map
drwxr-xr-x 3 hjs staff 96 23 Oct 11:08 update
Is there a way to specify the rights in sbt for the produced artefacts so I don't have to chmod everytime I compile?
For a use case see the Launcher App
drwxrwxrwx 1 SUPER.SUPER SUPER 4096 May 22 15:23 2018-05-22
drwxrwxrwx 1 SUPER.SUPER SUPER 4096 May 23 10:06 2018-05-23
drwxrwxrwx 1 SUPER.SUPER SUPER 4096 May 28 09:30 2018-05-28
drwxrwxrwx 1 SUPER.SUPER SUPER 4096 May 29 12:24 2018-05-29
-rw-r--r-- 1 SUPER.SUPER SUPER 48781 May 30 13:52 do.jck8b
-rw-r--r-- 1 SUPER.SUPER SUPER 48842 May 30 14:11 do.jck8b.64
drwxrwxrwx 1 SUPER.SUPER SUPER 4096 Jun 1 11:09 2018-06-01
i want only 4 files like this
sample output is..
drwxrwxrwx 1 SUPER.SUPER SUPER 4096 May 23 10:06 2018-05-23
drwxrwxrwx 1 SUPER.SUPER SUPER 4096 May 28 09:30 2018-05-28
drwxrwxrwx 1 SUPER.SUPER SUPER 4096 May 29 12:24 2018-05-29
drwxrwxrwx 1 SUPER.SUPER SUPER 4096 Jun 1 11:09 2018-06-01
enter code here
Could you please tell me how can i get those files
i am beginner of shell
I'm not sure what are you trying to achieve, but if you are interested in files starting with 2018, you can use a pattern with ls command.
For example:
ls 2018*
As i can see from your expected ouput, you are trying to print the directories and NOT the files having date format.
If you want to print only the directories of the date format having year as current year, you can simply use:
ls -lrt |grep ^d |grep "`date +%Y`"
I have just generated a new Symfony 3 project, and I have realized that directories has 755 permissions. For examppe, in project root directory:
drwxr-xr-x 3 me me 4096 oct 3 21:14 web
drwxr-xr-x 15 me me 4096 oct 10 12:08 vendor
drwxr-xr-x 5 me me 4096 oct 10 12:08 var
drwxr-xr-x 3 me me 4096 oct 10 12:08 tests
drwxr-xr-x 3 me me 4096 oct 10 12:08 src
drwxr-xr-x 2 me me 4096 oct 10 12:08 bin
drwxr-xr-x 4 me me 4096 oct 10 12:08 app
In case my current umask is 0002 so when I create a new directory (mkdir) at /tmp for example, the permissions are 775.
So why the Symfony directories has 755? Why did they choose that? Is this configurable?
Im on Ubuntu 14.04.
This is the command Im running
ls -l folder/file{[1-9],[1-9][0-9]}.txt
ls: folder/file[1-9][0-9].txt: No such file or directory
-rw-r--r-- 1 Craig staff 558 7 Jul 18:12 folder/file1.txt
-rw-r--r-- 1 Craig staff 250 7 Jul 18:12 folder/file2.txt
-rw-r--r-- 1 Craig staff 85 7 Jul 18:12 folder/file3.txt
-rw-r--r-- 1 Craig staff 18 7 Jul 18:12 folder/file4.txt
-rw-r--r-- 1 Craig staff 0 7 Jul 18:12 folder/file5.txt
I want to squelch the error line I get after the command so that it just doesn't show up the command would just look like
ls -l folder/file{[1-9],[1-9][0-9]}.txt
-rw-r--r-- 1 Craig staff 558 7 Jul 18:12 folder/file1.txt
-rw-r--r-- 1 Craig staff 250 7 Jul 18:12 folder/file2.txt
-rw-r--r-- 1 Craig staff 85 7 Jul 18:12 folder/file3.txt
-rw-r--r-- 1 Craig staff 18 7 Jul 18:12 folder/file4.txt
-rw-r--r-- 1 Craig staff 0 7 Jul 18:12 folder/file5.txt
Turning on the nullglob shell option will accomplish this:
$ ls file{[0-9],[1-9][0-9]}.txt
ls: cannot access file[1-9][0-9].txt: No such file or directory
file0.txt file1.txt file2.txt file3.txt file4.txt file5.txt
$ shopt -s nullglob
$ ls file{[0-9],[1-9][0-9]}.txt
file0.txt file1.txt file2.txt file3.txt file4.txt file5.txt
Add the shopt command to your .bashrc
Ref: https://www.gnu.org/software/bash/manual/bashref.html#Filename-Expansion
Given an ls -l list of directories which are software release versions, how to sort into human-preferable form? Eg:
$ ls -loghF
total 209
drwxr-xr-x 2 3 Jun 18 11:33 12.0.40.0/
drwxr-xr-x 2 3 Aug 24 14:45 13.0.11.10/
drwxr-xr-x 2 3 Jul 13 14:12 13.0.11.4/
drwxr-xr-x 2 3 Jul 26 15:30 13.0.11.5/
drwxr-xr-x 2 4 Jul 27 11:33 13.0.11.6/
drwxr-xr-x 2 3 Aug 3 11:41 13.0.11.7/
drwxr-xr-x 2 3 Aug 10 11:53 13.0.11.8/
drwxr-xr-x 2 3 Aug 17 17:00 13.0.11.9/
drwxr-xr-x 2 3 Aug 3 14:37 13.0.17.0/
drwxr-xr-x 2 3 Aug 13 11:50 13.0.18.0/
drwxr-xr-x 2 3 Aug 17 11:21 13.0.19.0/
drwxr-xr-x 2 3 Jul 28 15:00 13.0.9.1/
The desired result is:
$ ls -loghF | sort ...
total 209
drwxr-xr-x 2 3 Jun 18 11:33 12.0.40.0/
drwxr-xr-x 2 3 Jul 28 15:00 13.0.9.1/
drwxr-xr-x 2 3 Jul 13 14:12 13.0.11.4/
drwxr-xr-x 2 3 Jul 26 15:30 13.0.11.5/
drwxr-xr-x 2 4 Jul 27 11:33 13.0.11.6/
drwxr-xr-x 2 3 Aug 3 11:41 13.0.11.7/
drwxr-xr-x 2 3 Aug 10 11:53 13.0.11.8/
drwxr-xr-x 2 3 Aug 17 17:00 13.0.11.9/
drwxr-xr-x 2 3 Aug 24 14:45 13.0.11.10/
drwxr-xr-x 2 3 Aug 3 14:37 13.0.17.0/
drwxr-xr-x 2 3 Aug 13 11:50 13.0.18.0/
drwxr-xr-x 2 3 Aug 17 11:21 13.0.19.0/
The sort must skip past the date portion of each line, then sort numerically (eg, starting with the 12 or 13), using '.' as a field separator.
I thought of two approaches, but am having difficulty with the sort -k syntax, if it's supported at all:
(1) Skip the first 36 characters, then with '.' as field separator, sort numerically on the next 4 fields.
(2) With field separator as whitespace, skip to the 7th field, then change the field separator to '.' and sort numerically on the next 4 fields.
The alternate is a little Perl script, but can't Unix sort do this "simple" task?
Here's a command line which uses awk to put the version numbers first, sorts using four numerical keys, then uses cut to get rid of the temporary at front:
$ ls -loghF | awk '{ print $7, $0; }' | sort -n -t. -k1,1 -k2,2 -k3,3 -k4,4 | cut -d' ' -f2-
drwxr-xr-x 2 3 Jun 18 11:33 12.0.40.0/
drwxr-xr-x 2 3 Jul 28 15:00 13.0.9.1/
drwxr-xr-x 2 3 Jul 13 14:12 13.0.11.4/
drwxr-xr-x 2 3 Jul 26 15:30 13.0.11.5/
drwxr-xr-x 2 4 Jul 27 11:33 13.0.11.6/
drwxr-xr-x 2 3 Aug 3 11:41 13.0.11.7/
drwxr-xr-x 2 3 Aug 10 11:53 13.0.11.8/
drwxr-xr-x 2 3 Aug 17 17:00 13.0.11.9/
drwxr-xr-x 2 3 Aug 24 14:45 13.0.11.10/
drwxr-xr-x 2 3 Aug 3 14:37 13.0.17.0/
drwxr-xr-x 2 3 Aug 13 11:50 13.0.18.0/
drwxr-xr-x 2 3 Aug 17 11:21 13.0.19.0/
The sort command there is borrowed from this answer. Another answer suggests sort -V (version sort), but my version of sort doesn't have it (yours might, though, so it's worth trying). Version sort is likely to be specific to newer GNU coreutils (my Linux box has it, and sort is from GNU Coreutils 8.5).
With version sort:
$ ls -loghF | sort -k7,7V
drwxr-xr-x 2 3 Jun 18 11:33 12.0.40.0/
drwxr-xr-x 2 3 Jul 28 15:00 13.0.9.1/
drwxr-xr-x 2 3 Jul 13 14:12 13.0.11.4/
drwxr-xr-x 2 3 Jul 26 15:30 13.0.11.5/
drwxr-xr-x 2 4 Jul 27 11:33 13.0.11.6/
drwxr-xr-x 2 3 Aug 3 11:41 13.0.11.7/
drwxr-xr-x 2 3 Aug 10 11:53 13.0.11.8/
drwxr-xr-x 2 3 Aug 17 17:00 13.0.11.9/
drwxr-xr-x 2 3 Aug 24 14:45 13.0.11.10/
drwxr-xr-x 2 3 Aug 3 14:37 13.0.17.0/
drwxr-xr-x 2 3 Aug 13 11:50 13.0.18.0/
drwxr-xr-x 2 3 Aug 17 11:21 13.0.19.0/
This isn't the fastest way to do it, but it is fairly simple to explain:
ls -loghF |
awk '{ print $7 " " $0 }' |
sort -t. -k 1,1n -k 2,2n -k3,3n -k 4,4n |
sed 's/^[^ ]* //'
The 'awk' command copies the directory field to the front of the line; the sort command only uses a single delimiter (.; I don't think you can use different delimiters for different parts of a line) and then sorts the 4 numeric parts explicitly in numeric order. Then the sed removes the field that was added at the front.
This is a simple version of 'make it easy for sort to find the keys', because splitting the input is one of the expensive operations in sort.
FYI: Here's what I ended up doing.
Special thanks to: http://www.sysarch.com/Perl/sort_paper.html
$ ls -loghF | perl -e '
use strict;
my #in = <>;
my #out = grep(m|\d+\.\d+\.\d+\.\d+/$|, #in);
print sort {
my #aa = $a =~
m|(\d+)\.(\d+)\.(\d+)\.(\d+)/$|;
my #bb = $b =~
m|(\d+)\.(\d+)\.(\d+)\.(\d+)/$|;
$aa[0] <=> $bb[0] or
$aa[1] <=> $bb[1] or
$aa[2] <=> $bb[2] or
$aa[3] <=> $bb[3]
} #out;
'
drwxr-xr-x 2 3 Jun 18 11:33 12.0.40.0/
drwxr-xr-x 2 3 Jul 28 15:00 13.0.9.1/
drwxr-xr-x 2 3 Jul 13 14:12 13.0.11.4/
drwxr-xr-x 2 3 Jul 26 15:30 13.0.11.5/
drwxr-xr-x 2 4 Jul 27 11:33 13.0.11.6/
drwxr-xr-x 2 3 Aug 3 11:41 13.0.11.7/
drwxr-xr-x 2 3 Aug 10 11:53 13.0.11.8/
drwxr-xr-x 2 3 Aug 17 17:00 13.0.11.9/
drwxr-xr-x 2 3 Aug 24 14:45 13.0.11.10/
drwxr-xr-x 2 3 Aug 29 17:31 13.0.11.11/
drwxr-xr-x 2 3 Aug 3 14:37 13.0.17.0/
drwxr-xr-x 2 3 Aug 13 11:50 13.0.18.0/
drwxr-xr-x 2 3 Aug 17 11:21 13.0.19.0/