由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Programming版 - linux, find command question
相关主题
简单的perl问题弱问perl写网页buffer问题
一个没想明白的问题如何检测malicious clicks on search results?
Kernel Programming Question: timestamp and synchronization怎么样实现fuzzy join
10G文件的排序问题一个SQL的题目
how to count the times a function is used急请教:用java实现解析parse一个log文件,多谢指点
how to convert GMT to timestamp of the computer's current time大家说怎么实现Snapshot isolation
一个python script同时写一万多个文本文件关于古德霸反例的实际测试数据
Clearcase 的一点疑问data consistency
相关话题的讨论汇总
话题: timestamp话题: find话题: usr话题: files话题: level
进入Programming版参与讨论
1 (共1页)
e****d
发帖数: 333
1
how to find all sub directories, where the target file lives, but no deepper
level?
for example, we have timestamp files for each directory, but we don't want
to find subfolder timestamp files any more. the files look like this
/usr/local/timestamp
/usr/local/bin/timestamp
/usr/local/lib/timestamp
/usr/name/timestamp
/media/v1/
/home/jk/
now we run a find command: find ???? timestamp
we get two files
/usr/local/timestamp
/usr/name/timestamp
all deeper level timestamps are not shown.
how to do this find???
d***a
发帖数: 13752
2
find . -name timestamp -depth 3
e****d
发帖数: 333
3
this does not work, in reality, the directory can be arbitrarily deep,
timestamp can show up for the first time in any depth, any level. we just
want to have the parent level, all child level should be ignored.

【在 d***a 的大作中提到】
: find . -name timestamp -depth 3
d***a
发帖数: 13752
4
find . -name timestamp -prune

【在 e****d 的大作中提到】
: this does not work, in reality, the directory can be arbitrarily deep,
: timestamp can show up for the first time in any depth, any level. we just
: want to have the parent level, all child level should be ignored.

e****d
发帖数: 333
5
that does not work. we don't want to discard all path including timestamp
we want to have a subset of path which include timestamp.
The subset are the parent level of timestamp folders. if any timestamp file
is in a subfolder, the subfolder will be discarded in the results.
for example:
/parent/timestamp
/parent/children/timestamp
we want to have only /parent/timestamp in results.
thanks.

【在 d***a 的大作中提到】
: find . -name timestamp -prune
e*******o
发帖数: 4654
6
写个脚本吧 为啥非得用find

file

【在 e****d 的大作中提到】
: that does not work. we don't want to discard all path including timestamp
: we want to have a subset of path which include timestamp.
: The subset are the parent level of timestamp folders. if any timestamp file
: is in a subfolder, the subfolder will be discarded in the results.
: for example:
: /parent/timestamp
: /parent/children/timestamp
: we want to have only /parent/timestamp in results.
: thanks.

d***a
发帖数: 13752
7
find . -name timestamp -prune | awk -F/ '{print $2"/timestamp";}' | awk '!x[
$0]++'

file

【在 e****d 的大作中提到】
: that does not work. we don't want to discard all path including timestamp
: we want to have a subset of path which include timestamp.
: The subset are the parent level of timestamp folders. if any timestamp file
: is in a subfolder, the subfolder will be discarded in the results.
: for example:
: /parent/timestamp
: /parent/children/timestamp
: we want to have only /parent/timestamp in results.
: thanks.

e****d
发帖数: 333
8
this does not work. timestamp is a file, once we find such a file in a
folder, say folder A, all subfolders of this found folder will be skiped.

【在 d***a 的大作中提到】
: find . -name timestamp -prune | awk -F/ '{print $2"/timestamp";}' | awk '!x[
: $0]++'
:
: file

d***a
发帖数: 13752
9
find . -name timestamp -prune | awk -F/ '{print $2"/timestamp";}' | awk '!x[
$0]++'

【在 e****d 的大作中提到】
: this does not work. timestamp is a file, once we find such a file in a
: folder, say folder A, all subfolders of this found folder will be skiped.

d***a
发帖数: 13752
10
呵呵,想起以前做coding project的时候,最大的问题不是编程,而是用户需求分析。
n*****t
发帖数: 22014
11
find | sort | awk
比较 last current 两行的 dirname,好像想不出更巧妙的办法 。。。

deepper

【在 e****d 的大作中提到】
: how to find all sub directories, where the target file lives, but no deepper
: level?
: for example, we have timestamp files for each directory, but we don't want
: to find subfolder timestamp files any more. the files look like this
: /usr/local/timestamp
: /usr/local/bin/timestamp
: /usr/local/lib/timestamp
: /usr/name/timestamp
: /media/v1/
: /home/jk/

1 (共1页)
进入Programming版参与讨论
相关主题
data consistencyhow to count the times a function is used
拿Cassandra当MQ用,证明你连Cassandra也不懂how to convert GMT to timestamp of the computer's current time
unix timestamp一个python script同时写一万多个文本文件
吐槽 MySQLClearcase 的一点疑问
简单的perl问题弱问perl写网页buffer问题
一个没想明白的问题如何检测malicious clicks on search results?
Kernel Programming Question: timestamp and synchronization怎么样实现fuzzy join
10G文件的排序问题一个SQL的题目
相关话题的讨论汇总
话题: timestamp话题: find话题: usr话题: files话题: level