ls

Listing entries in a directory using grep

旧巷老猫 提交于 2019-12-10 09:49:22
问题 I'm trying to list all entries in a directory whose names contain ONLY upper-case letters. Directories need "/" appended. #!/bin/bash cd ~/testfiles/ ls | grep -r *.* Since grep by default looks for upper-case letters only (right?), I'm just recursively searching through the directories under testfiles for all names who contain only upper-case letters. Unfortunately this doesn't work. As for appending directories, I'm not sure why I need to do this. Does anyone know where I can start with

Absolute path to Relative Path in Unix

六月ゝ 毕业季﹏ 提交于 2019-12-08 09:54:32
问题 This command was to list only the text files in my fileAsst directory: ls ~/UnixCourse/fileAsst/*.txt now I need to do the same thing but using a relative path instead, what I've tried so far is: ls ~/UnixCourse/../*.txt but it's saying I'm not getting the right answer, can anyone give me some hints or explain the differences between a relative path and absolute path, because I still dont under it. 回答1: Relative is always, well, relative to some existing directory, you are currently "located"

In the macOS terminal, “ls | mdls” commands are only working for the home directory

老子叫甜甜 提交于 2019-12-08 09:23:28
问题 I would like a list of all the date added metadata for my Downloads folder on macOS. I found the following code (for macOS terminal) from http://forums.ilounge.com/applescripts-itunes-mac/100189-mdls-command-tiger.html, but it only works for the home directory. Adding a different directory as a modifier doesn't work, and using cd doesn't work. When I do those things, it still returns the results of the home directory. How do I get it to work for my Downloads folder, or is there another

combining matrix by name

南楼画角 提交于 2019-12-08 06:56:57
问题 I have a set of matrix named gof_1_1 , gof_1_2 , ..... , gof_1_24 . I want to combine all of them in to one matrix along the columns. So am using the following code do.call(cbind,mget(ls(pattern = paste("gof",1,"[0-9]",sep="_"), globalenv()))) It combines the matrix, but problem is they are not in an order. They go like this gof_1_1 , gof_1_11 , gof_1_12 , ..... , gof_1_19 , gof_1_2 , gof_1_21 and so on. So I edited the ls() as shown below ls(pattern = paste("gof",1,"[0-9][0-9]",sep="_")

Cleartool - List Objects with Their Labels

China☆狼群 提交于 2019-12-08 06:49:36
问题 I want to list all objects (including files and directories) recursively with labels their have. When I run the following command, it writes only Rule. It does not write all labels on any object. cleartool ls -r -l /view/stable/MYVOB/MyProject Result : version /view/stable/MYVOB/Car.java@@/main/3 Rule: element * TO_TEST version /view/stable/MYVOB/Driver.java@@/main/2 Rule: element * TO_TEST How can I list the all labels ? In addition, listing modifiers and modification date will be plus for

GNU ls from Coreutils missing OS X ACL implementation

不羁岁月 提交于 2019-12-07 15:04:25
I'm using brew to retrieve and install common GNU versions of terminal commands and utils with brew install coreutils . Then in my .bash_profile I'm including their PATH with if [ -d $(brew --prefix coreutils)/libexec/gnubin ]; then PATH="$(brew --prefix coreutils)/libexec/gnubin:$PATH" fi so far so good, I can use use the GNU version of coreutils. The problem comes from ls . Apple implement ACL that is not implemented on GNU ls . I discovered this by banging my head many times and not understanding why (for example) ls -le@ would give me error ls: invalid option -- 'e' . So now I understood

Bash list files with range

五迷三道 提交于 2019-12-06 14:54:54
问题 My script has to list all files between a given range of date within a file name (ex: 20130133.212001.log). The start date and end date will be given by user. I now have start_year, end_year, start_month, end_month....so on till end_second. My plan was to use ls syntax: ls *{start_year..end_year}{start_month..end_month}{.....}.log But the problem is if month or date has 01 bash is taking it as 1. Indeed my bash version is older than 4. I can't considering updating the bash version. Any other

Hiding function names from ls() results - to find a variable name more quickly

≡放荡痞女 提交于 2019-12-06 04:08:40
问题 When we have defined tens of functions - probably to develop a new package - it is hard to find out the name of a specific variable among many function names through ls() command. In most of cases we are not looking for a function name - we already know they exist - but we want to find what was the name we assigned to a variable. Any idea to solve it is highly appreciated. 回答1: If you want a function to do this, you need to play around a bit with the environment that ls() looks in. In normal

一个多进程并发执行程序ps命令 ls命令

你说的曾经没有我的故事 提交于 2019-12-06 01:28:55
实验要求:编写一个多进程并发执行程序。父进程首先创建一个执行 ls 命令的子进程然//后再创建一个执行ps 命令的子进程,并控制ps 命令总在 ls 命令之前执行。 //Copyright:(C) 2013.4 By ZhengDujin //Linux Ubuntu12.04 Gcc Vim #include <unistd.h> #include <sys/types.h> #include <sys/wait.h> #include <signal.h> #include <stdio.h> #include <stdlib.h> typedef void (*sighandler_t)(int); void sigcat(){ printf("Coming back to the process %d.\n",getpid()); } int main(){ int status;//存放子进程返回状态 pid_t pls,pps;//存放子进程号 signal(SIGINT,(sighandler_t)sigcat);//注册一个本进程处理键盘中断的函数 char *args1[]={"/bin/ls","-a",NULL}; char *args2[]={"/bin/ps","-l",NULL}; pls=fork();//创建子进程运行命令 /bin/ls /

Using grep and ls in FTP client?

怎甘沉沦 提交于 2019-12-05 19:27:43
How could I use grep and ls in FTP client... I mean if I want to find some specific file I could use: ls -l | grep pattern lftp can, exactly the way you typed. With the usual Unix commandline interactive ftp, one approach is: Remote system type is UNIX. Using binary mode to transfer files. ftp> dir . foobar output to local-file: foobar [anpqy?]? y 500 Unknown command 227 Entering Passive Mode (62,149,140,15,195,159) 150 Accepted data connection 11966 5.26 KB/s 226-Options: -a -l 226 156 matches total ftp> !grep con foobar -rwxr-xr-x 1 11050207 users 911007 Sep 13 2007 accu_pyconc.pdf -rwxr-xr