Squelching an ls warning/error - unix

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

Related

Generate Xamarin.iOS bindings for HERE SDK 4

I'm trying to create the Xamarin.iOS bindings for the HERE SDK 4:
sudo xcode-select -s /Applications/Xcode_12.4.app
cd heresdk-navigate-ios-4.11.0.0.8255/heresdk.xcframework/ios-arm64
sharpie bind -sdk iphoneos14.4 -framework heresdk.framework
but I only receive this error:
Parsing 1 header files...
Binding...
System.BadImageFormatException: Invalid Image
File name: '/Library/Frameworks/Xamarin.iOS.framework/Versions/Current/lib/mono/Xamarin.iOS/Xamarin.iOS.dll'
at (wrapper managed-to-native) System.Reflection.Assembly.LoadFrom(string,bool,System.Threading.StackCrawlMark&)
at System.Reflection.Assembly.LoadFrom (System.String assemblyFile) [0x00002] in /Users/builder/jenkins/workspace/build-package-osx-mono/2020-02/external/bockbuild/builds/mono-x64/mcs/class/corlib/System.Reflection/Assembly.cs:367
at Sharpie.Bind.Massagers.XamarinApiMappingMassager.Initialize () [0x0002c] in /Users/runner/work/1/s/Sharpie.Bind/Massagers/XamarinApiMappingMassager.cs:50
no types were parsed that could be bound
This is the content of the folder heresdk.framework:
% cd heresdk.framework
% ls -la
total 789992
drwx------ 21 672 May 3 17:07 .
drwx------ 4 128 May 6 14:03 ..
-rw------- 1 5755 Apr 6 10:53 HERE_logo_full.svg
-rw------- 1 5815 Apr 6 10:53 HERE_logo_full_inverted.svg
drwx------ 3 96 May 3 17:06 Headers
-rw------- 1 799 Apr 6 10:52 Info.plist
drwx------ 4 128 May 3 17:06 Modules
drwx------ 3 96 May 3 17:06 _CodeSignature
-rw------- 1 6106 Apr 6 10:53 arrow_cap_medium.obj
drwx------ 9 288 May 3 17:07 geoviz
-rw------- 1 404087792 Apr 6 11:16 heresdk
-rw------- 1 3793 Apr 6 10:53 location_indicator_halo.obj
-rw------- 1 11521 Apr 6 10:53 location_indicator_halo.png
-rw------- 1 20180 Apr 6 10:53 location_indicator_navigation.obj
-rw------- 1 81093 Apr 6 10:53 location_indicator_navigation.png
-rw------- 1 81058 Apr 6 10:53 location_indicator_navigation_gray.png
-rw------- 1 40165 Apr 6 10:53 location_indicator_pedestrian.obj
-rw------- 1 45677 Apr 6 10:53 location_indicator_pedestrian.png
-rw------- 1 45907 Apr 6 10:53 location_indicator_pedestrian_gray.png
drwx------ 4 128 May 3 17:06 magma
drwx------ 47 1504 May 3 17:07 voice_assets
Any ideas what I might missed?
Sorry to say that, we are currently not supporting xamarin. but some customer have implemented that support on their own in the past. Could you please refer the xamarin official doc
https://learn.microsoft.com/en-us/xamarin/?WT.mc_id=dotnet-35129-website

How do I specify permissions for sbt artefacts

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

How to delete all folders except latest 3 folders in efficient way in unix

-rw-r--r-- 1 SUPER.SUPER SUPER 48615 May 30 11:47 do.jck8b
-rw-r--r-- 1 SUPER.SUPER SUPER 48629 May 30 11:47 do.jck8b.64
drwxrwxrwx 1 SUPER.SUPER SUPER 4096 May 30 12:16 2018-05-28
drwxrwxrwx 1 SUPER.SUPER SUPER 4096 May 30 14:28 J22
drwxrwxrwx 1 SUPER.SUPER SUPER 4096 Jun 4 15:54 2018-05-29
drwxrwxrwx 1 SUPER.SUPER SUPER 4096 Jun 4 15:54 2018-05-23
drwxrwxrwx 1 SUPER.SUPER SUPER 4096 Jun 4 21:26 2018-05-22
My requirement is delete all the folders except latest 3 folders,
Sample output is:
2018-05-29
2018-05-23
2018-05-22
I tried this way but it takes lots of time to delete , is ther any alterbative way to do this...
find . -name "*" | grep -v 2018-05-29 | grep -v 2018-05-23 | grep -v 2018-05-22 | grep -v do.jck | xargs rm -rf
By last modified time
# Starting with these directory contents
$ ls -l
total 24
drwxr-xr-x 2 chuckx chuckx 4096 Jun 5 08:27 2018-05-25
drwxr-xr-x 2 chuckx chuckx 4096 Jun 5 08:26 2018-05-26
drwxr-xr-x 2 chuckx chuckx 4096 Jun 4 23:29 2018-05-27
drwxr-xr-x 2 chuckx chuckx 4096 Jun 4 23:29 2018-05-28
drwxr-xr-x 2 chuckx chuckx 4096 Jun 4 23:29 2018-05-29
-rw-r--r-- 1 chuckx chuckx 98 Jun 4 23:29 mkdirs.sh
# List only directories and sort by reversed modified time
$ ls -dlrt */
drwxr-xr-x 2 chuckx chuckx 4096 Jun 4 23:29 2018-05-29/
drwxr-xr-x 2 chuckx chuckx 4096 Jun 4 23:29 2018-05-28/
drwxr-xr-x 2 chuckx chuckx 4096 Jun 4 23:29 2018-05-27/
drwxr-xr-x 2 chuckx chuckx 4096 Jun 5 08:26 2018-05-26/
drwxr-xr-x 2 chuckx chuckx 4096 Jun 5 08:27 2018-05-25/
# Removed the detailed listing to just get filenames
$ ls -drt */
2018-05-29/ 2018-05-28/ 2018-05-27/ 2018-05-26/ 2018-05-25/
# Strip the last three lines (i.e. the most recent directories)
$ ls -drt */ | head -n -3
2018-05-29/
2018-05-28/
# Pipe the results to xargs to execute rmdir
$ ls -drt */ | head -n -3 | xargs rmdir
# Look at the results
$ ls
2018-05-25 2018-05-26 2018-05-27 mkdirs.sh
By date embedded in filename
# Starting with these directory contents
$ ls
2018-05-25 2018-05-26 2018-05-27 2018-05-28 2018-05-29 mkdirs.sh
# List only the directories
$ ls -d */
2018-05-25/ 2018-05-26/ 2018-05-27/ 2018-05-28/ 2018-05-29/
# Pipe to sort, just to be certain
$ ls -d */ | sort
2018-05-25/
2018-05-26/
2018-05-27/
2018-05-28/
2018-05-29/
# Strip the last three lines (i.e. most recent directories)
$ ls -d */ | sort | head -n -3
2018-05-25/
2018-05-26/
# Pipe the results to xargs to execute rmdir
$ ls -d */ | sort | head -n -3 | xargs rmdir
# Look at the results
$ ls
2018-05-27 2018-05-28 2018-05-29 mkdirs.sh

Symfony 3.4 creates "prod?" cache directory

I'm currently using Symfony 3.4.8 with up to date dependencies.
In production, symfony creates "prod?" directory :
drwxrwxrwx 4 www-data www-data  434 Apr 20 10:26 .
drwxr-xr-x 4 www-data www-data   45 Apr 20 10:21 ..
-rw-rw-rw- 1 www-data www-data  165 Apr 20 10:26 annotations.map
drwxrwxrwx 2 www-data www-data  15K Apr 20 10:26 ContainerDcnvgsr
-rw-rw-rw- 1 www-data www-data 106K Apr 20 10:26 srcProd?DebugProjectContainerCompiler.log
-rw-rw-rw- 1 www-data www-data  628 Apr 20 10:26 srcProd?DebugProjectContainerDeprecations.log
-rw-rw-rw- 1 www-data www-data  784 Apr 20 10:26 srcProd?DebugProjectContainer.php
-rw-rw-rw- 1 www-data www-data  21K Apr 20 10:26 srcProd?DebugProjectContainer.php.meta
-rw-rw-rw- 1 www-data www-data 347K Apr 20 10:21 srcProd?DebugProjectContainer.xml
-rw-rw-rw- 1 www-data www-data  21K Apr 20 10:21 srcProd?DebugProjectContainer.xml.meta
drwxrwxrwx 2 www-data www-data    0 Apr 20 10:21 vich_uploader
var/cache directory :
drwxr-xr-x 4 www-data www-data  45 Apr 20 10:21 .
drwxr-xr-x 4 www-data www-data  44 Apr 19 11:38 ..
drwxr-xr-x 9 www-data www-data 556 Apr 19 11:42 prod
drwxrwxrwx 4 www-data www-data 434 Apr 20 10:26 prod?
public directory :
drwxr-xr-x 3 www-data www-data  104 Apr 19 11:39 build
drwxr-xr-x 2 www-data www-data   27 Apr 19 11:38 bundles
drwxrwxrwx 2 www-data www-data   98 Apr 19 09:27 imports
-rw-rw-rw- 1 www-data www-data 1242 Apr 19 09:27 index.php
Most of users have the following error :
(1/1) FatalThrowableError
Parse error: syntax error, unexpected
'DebugProjectContainer' (T_STRING), expecting ',' or ')'
The app works for few users with the correct "prod" cache directory and no error.
How can I fix this ?
There was a special character (^M) at the end of each line in the .env file due to a bad copy/paste.
¯\_(ツ)_/¯

Unix (Solaris) sort of ls -l output, with numeric names

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/

Resources