服务器之家

服务器之家 > 正文

写给iOS程序员的命令行使用秘籍

时间:2021-01-09 17:15     来源/作者:iOS开发网

mac os是unix系统的分支,有着强大的命令行功能。很多事情在命令行下处理会事半功倍,所以我就ios程序员可能会用到的功能讲述一下。

终端设置

mac的终端有一个很关键的配置,就是“使用 option 键作为 meta 键”。勾上这个选项之后,就可以使用emacs的编辑命令了。

写给iOS程序员的命令行使用秘籍

我发现有些人的终端没有设置“平滑文本”,导致终端上的文字很难看。赶紧把这个选项勾上吧。

写给iOS程序员的命令行使用秘籍

常用的几个快捷键如下。

control+a,跳到命令行开始位置;control+e,跳到命令行结尾位置。
option+f,向后跳一个word;option+b,向前跳一个word。
option+d,向后删除一个word;option+delete,向前删除一个word。
control+_,撤销之前一次编辑操作。
control+k,删除到行尾;control+u,删除到行首。

终端颜色高亮也不错,看起来感觉会更有感觉。比如ls可以看到目录会是蓝色的,普通文件是白色的,可执行程序会是绿色的。

写给iOS程序员的命令行使用秘籍

homebrew

homebrew是一个非常有用包管理工具,通过homebrew可以安装更多有用的unix工具,比如wget、tree等等。

安装

目前最好的安装方式都是下面这样的,一句命令搞定。

?
1
ruby -e "$(curl -fssl https://raw.githubusercontent.com/homebrew/install/master/install)"

使用

?
1
2
3
4
5
[~]$ brew install tree
==> downloading http://mama.indstate.edu/users/ice/tree/src/tree-1.7.0.tgz
already downloaded: /library/caches/homebrew/tree-1.7.0.tgz
==> make prefix=/usr/local/cellar/tree/1.7.0 mandir=/usr/local/cellar/tree/1.7.0/share/man/man1 cc=clang cflags=-fomit-frame-pointer ld
/usr/local/cellar/tree/1.7.0: 7 files, 128k, built in 2 seconds

tree这个工具看目录的内容非常直观好看。

 

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
[~/ilaiwang/lwshareto]$ tree
.
├── lwshareto
│  ├── lwsharecontent.h
│  ├── lwsharecontent.m
│  ├── lwshareto-prefix.pch
│  ├── lwshareto.h
│  ├── lwshareto.m
│  ├── lwsharetomacro.h
│  ├── lwsharetoutils.h
│  ├── lwsharetoutils.m
│  ├── sharemodule
│  │  ├── lwsharechannelservice.h
│  │  ├── lwsharechannelservice.m
│  │  ├── lwsharetobaseclass.h
│  │  ├── lwsharetobaseclass.m
│  │  ├── lwsharetoclipboard.h
│  │  ├── lwsharetoclipboard.m
│  │  ├── lwsharetodouban.h
│  │  ├── lwsharetodouban.m
│  │  ├── lwsharetoinside.h
│  │  ├── lwsharetoinside.m
│  │  ├── lwsharetolwfeed.h
│  │  ├── lwsharetolwfeed.m
│  │  ├── lwsharetolwsession.h
│  │  ├── lwsharetolwsession.m
│  │  ├── lwsharetooutside.h
│  │  ├── lwsharetooutside.m
│  │  ├── lwsharetoqqsession.h
│  │  ├── lwsharetoqqsession.m
│  │  ├── lwsharetoqqzone.h
│  │  ├── lwsharetoqqzone.m
│  │  ├── lwsharetorenren.h
│  │  ├── lwsharetorenren.m
│  │  ├── lwsharetosinaweibo.h
│  │  ├── lwsharetosinaweibo.m
│  │  ├── lwsharetotencentweibo.h
│  │  ├── lwsharetotencentweibo.m
│  │  ├── lwsharetowechatsession.h
│  │  ├── lwsharetowechatsession.m
│  │  ├── lwsharetowechattimeline.h
│  │  └── lwsharetowechattimeline.m
│  ├── webviewrender.h
│  └── webviewrender.m
├── lwshareto.xcodeproj
│  └── project.pbxproj
└── lwsharetotests
  ├── lwsharetotests-info.plist
  ├── lwsharetotests.m
  └── en.lproj
    └── infoplist.strings
 
5 directories, 44 files

shell

gnu coreutils包含了各种gnu好用的工具。根据我的观察,我发现mac预装了coreutils,只是版本比较低,建议自己安装一下,否者sort连”-h”参数都没有。

写给iOS程序员的命令行使用秘籍

xcode图形化操作挺好用的,不过知道一些命令行的操作会更佳。在下面这个地方看到xcode编译的详细过程。

写给iOS程序员的命令行使用秘籍

如果在编译的时候遇到链接错误,在命令行下检查一下就非常有必要了。下面这个命令就是链接生成来往二进制程序的,可以拷贝到终端里面运行。如果链接出错误了,可以仔细检查一下这个命令。

?
1
2
3
4
5
ld /users/henshao/library/developer/xcode/deriveddata/laiwang-fxscnxkslrypubbeazdfkveysldy/build/products/debug-iphoneos/laiwang.app/laiwang normal arm64
  cd /users/henshao/ilaiwang/laiwangv3
  export iphoneos_deployment_target=6.0
  export path="/applications/xcode.app/contents/developer/platforms/iphoneos.platform/developer/usr/bin:/applications/xcode.app/contents/developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
  /applications/xcode.app/contents/developer/toolchains/xcodedefault.xctoolchain/usr/bin/clang++ -arch arm64 -isysroot /applications/xcode.app/contents/developer/platforms/iphoneos.platform/developer/sdks/iphoneos8.3.sdk -l/users/henshao/library/developer/xcode/deriveddata/laiwang-fxscnxkslrypubbeazdfkveysldy/build/products/debug-iphoneos -l/users/henshao/ilaiwang/laiwangv3/../pods/lwcomponentkits/lwcomponentkits/amap/liboffset -l/users/henshao/ilaiwang/laiwangv3/../pods/lwxiamimusic/output -l/users/henshao/ilaiwang/laiwangv3/../pods/qupaisdk/libqupaisdk -l/users/henshao/ilaiwang/laiwangv3/../pods/voipsdk/sdk/lib -f/users/henshao/library/developer/xcode/deriveddata/laiwang-fxscnxkslrypubbeazdfkveysldy/build/products/debug-iphoneos -f/users/henshao/ilaiwang/laiwangv3/../pods/amap3dmap -f/users/henshao/ilaiwang/laiwangv3/../pods/amapsearch -f/users/henshao/ilaiwang/laiwangv3/../pods/deviceprint -f/users/henshao/ilaiwang/laiwangv3/../pods/tbsecuritysdk -f/users/henshao/ilaiwang/laiwangv3/../pods/securityguardsdk -f/users/henshao/ilaiwang/laiwangv3/../pods/usertrack -f/users/henshao/ilaiwang/laiwangv3/../pods/plcrashreporter/ios\ framework -f/users/henshao/ilaiwang/laiwangv3/../pods/mtopsdk -f/users/henshao/ilaiwang/laiwangv3/../pods/speechrecognizer -f/users/henshao/ilaiwang/laiwangv3/../pods/tbscanlib -f/users/henshao/ilaiwang/laiwangv3/../pods/tbshorturl -f/users/henshao/ilaiwang/laiwangv3 -f/users/henshao/ilaiwang/laiwangv3/../pods/tencentopenapisdk/64bit -f/users/henshao/ilaiwang/laiwangv3/../pods/huoyansdk_laiwang -f/users/henshao/ilaiwang/laiwangv3/../pods/mtopext -f/users/henshao/ilaiwang/laiwangv3/laiwang/lwuikits/alipaysdk_2 -f. -flaiwang -flaiwangshare -flaiwangtests -flaiwang/baseframe -flaiwang/baselogic -flaiwang/cache -flaiwang/dataprovider -flaiwang/datasource -flaiwang/devtools -flaiwang/h5_slider_local -flaiwang/init -flaiwang/integration -flaiwang/lwsafemode -flaiwang/lwuikits -flaiwang/pageviews -flaiwang/sdk -flaiwang/sounds -flaiwang/testutility -flaiwang/usercontrols -flaiwang/utils -flaiwangtests/lwservicetests -flaiwangtests/other -flaiwang/baseframe/lwcontroller -flaiwang/baseframe/lwuisdk -flaiwang/baseframe/urlcoordinator -flaiwang/cache/lwdatacache -flaiwang/cache/lwdb -flaiwang/cache/lwdbmodel -flaiwang/h5_slider_local/app.slide -flaiwang/integration/lwservice -flaiwang/integration/lwservicetests -flaiwang/lwuikits/alipaysdk_2 -flaiwang/lwuikits/lwalbumphotopreview -flaiwang/lwuikits/lwcameracaptureview -flaiwang/lwuikits/lwmovieview -flaiwang/lwuikits/mmdrawercontroller -flaiwang/lwuikits/tableviewcell -flaiwang/pageviews/albumpage -flaiwang/pageviews/chatpage -flaiwang/pageviews/discoveryexpage -flaiwang/pageviews/emotionboxpage -flaiwang/pageviews/eventpage -flaiwang/pageviews/feedpage -flaiwang/pageviews/friendpage -flaiwang/pageviews/friendradarpage -flaiwang/pageviews/introducepage -flaiwang/pageviews/knockpage -flaiwang/pageviews/loginpage -flaiwang/pageviews/minepage -flaiwang/pageviews/morepage -flaiwang/pageviews/moviepage -flaiwang/pageviews/musicpage -flaiwang/pageviews/nearbypage -flaiwang/pageviews/newguidepage -flaiwang/pageviews/notificationpage -flaiwang/pageviews/oauthpage -flaiwang/pageviews/photoeditorpage -flaiwang/pageviews/photofilterpage -flaiwang/pageviews/postpage -flaiwang/pageviews/pubaccountpage -flaiwang/pageviews/searchpage -flaiwang/pageviews/sharedpage -flaiwang/pageviews/sharemsgpage -flaiwang/pageviews/xiamipage -flaiwang/sdk/eggshell -flaiwang/sdk/internalsdk -flaiwang/sdk/lwfileuploadmanager -flaiwang/sdk/lwhostservice -flaiwang/sdk/lwshareto -flaiwang/sdk/ssoapiengine -flaiwang/sdk/viewmodels -flaiwang/sdk/voip -flaiwang/sounds/asr -flaiwang/sounds/radar -flaiwang/testutility/apnstest -flaiwang/testutility/timecounter -flaiwang/usercontrols/bigimagecontrol -flaiwang/usercontrols/lwasrboard -flaiwang/usercontrols/lwavatarview -flaiwang/usercontrols/lwbrowserviewcontroller -flaiwang/usercontrols/lwcloudaudioplayerbox -flaiwang/usercontrols/lwcustomui -flaiwang/usercontrols/lweasyinputview -flaiwang/usercontrols/lwemotionview -flaiwang/usercontrols/lwlocationdirectionview -flaiwang/usercontrols/lwlocationdisplayview -flaiwang/usercontrols/lwnativebridgewebview -flaiwang/usercontrols/lwobjselectcontrol -flaiwang/usercontrols/lwpicker -flaiwang/usercontrols/lwpictureviewer -flaiwang/usercontrols/lwprogressview -flaiwang/usercontrols/lwrichtextcontentview -flaiwang/usercontrols/lwscrolltabbar -flaiwang/usercontrols/lwsettingsitem -flaiwang/usercontrols/lwtextzoomview -flaiwang/usercontrols/lwtoastview -flaiwang/usercontrols/lwvoicewidget -flaiwang/usercontrols/lwvoipview -flaiwang/usercontrols/lwwebimageview -flaiwang/usercontrols/lwwebviewcontroller -flaiwang/usercontrols/lwxiamibar -flaiwang/usercontrols/qbimagepicker -flaiwang/utils/abcontact -flaiwang/utils/alassetslibrary-customphotoalbum -flaiwang/utils/asr -flaiwang/utils/awactionsheet -flaiwang/utils/category -flaiwang/utils/compatibleutil -flaiwang/utils/gdataxmlnode -flaiwang/utils/huoyan -flaiwang/utils/imagedownloader -flaiwang/utils/lwappurlnavigator -flaiwang/utils/lwbizsearch -flaiwang/utils/lwdatastore -flaiwang/utils/lwfav -flaiwang/utils/lwlocalpageurlrouter -flaiwang/utils/lwlocationmanager -flaiwang/utils/lwmusic -flaiwang/utils/lwpushdispatcher -flaiwang/utils/lwstatistics -flaiwang/utils/nsstringadditions -flaiwang/utils/offlinesendutil -flaiwang/utils/qupaisdk -flaiwang/utils/sdwebimage -flaiwang/utils/soundeffect -flaiwang/utils/uiimageadditions -flaiwang/utils/uiimagepickercontrolleradditions -flaiwang/utils/ut -flaiwang/baseframe/lwcontroller/lwtabbarcontroller -flaiwang/h5_slider_local/app.slide/css -flaiwang/h5_slider_local/app.slide/images -flaiwang/h5_slider_local/app.slide/js -flaiwang/integration/lwservice/ios -flaiwang/integration/lwservicetests/lwpacktests -flaiwang/integration/lwservicetests/lwservicetests -flaiwang/lwuikits/alipaysdk_2/alipaysdk.bundle -flaiwang/pageviews/albumpage/cells -flaiwang/pageviews/albumpage/usercontrols -flaiwang/pageviews/chatpage/bubbleday -flaiwang/pageviews/chatpage/cells -flaiwang/pageviews/chatpage/messagesender -flaiwang/pageviews/chatpage/momochat -flaiwang/pageviews/chatpage/usercontrols -flaiwang/pageviews/eventpage/eventcommon -flaiwang/pageviews/eventpage/eventcreate -flaiwang/pageviews/eventpage/eventdeprecated -flaiwang/pageviews/eventpage/eventlist -flaiwang/pageviews/eventpage/eventlottery -flaiwang/pageviews/eventpage/eventmain -flaiwang/pageviews/eventpage/eventnotification -flaiwang/pageviews/eventpage/eventpostdetail -flaiwang/pageviews/eventpage/eventrecent -flaiwang/pageviews/eventpage/eventrecommend -flaiwang/pageviews/eventpage/eventsearch -flaiwang/pageviews/eventpage/eventsetting -flaiwang/pageviews/eventpage/eventwall -flaiwang/pageviews/eventpage/eventzan -flaiwang/pageviews/eventpage/pubeventrecent -flaiwang/pageviews/feedpage/cells -flaiwang/pageviews/feedpage/usercontrols -flaiwang/pageviews/friendpage/cells -flaiwang/pageviews/friendpage/usercontrols -flaiwang/pageviews/friendradarpage/pscollectionview -flaiwang/pageviews/friendradarpage/pulsinghalo -flaiwang/pageviews/friendradarpage/rnblurmodalview -flaiwang/pageviews/knockpage/answer -flaiwang/pageviews/knockpage/browse -flaiwang/pageviews/knockpage/knocklist -flaiwang/pageviews/knockpage/setquestion -flaiwang/pageviews/knockpage/setting -flaiwang/pageviews/knockpage/statistic -flaiwang/pageviews/knockpage/usercontrols -flaiwang/pageviews/knockpage/voicecard -flaiwang/pageviews/minepage/usercontrols -flaiwang/pageviews/morepage/cells -flaiwang/pageviews/notificationpage/cells -flaiwang/pageviews/notificationpage/usercontrols -flaiwang/pageviews/photoeditorpage/dataprovider -flaiwang/pageviews/photoeditorpage/dbmodel -flaiwang/pageviews/photoeditorpage/usercontrols -flaiwang/pageviews/postpage/cells -flaiwang/pageviews/postpage/usercontrols -flaiwang/pageviews/pubaccountpage/cells -flaiwang/pageviews/pubaccountpage/pubtoolbar -flaiwang/pageviews/pubaccountpage/usercontrols -flaiwang/pageviews/searchpage/searchcell -flaiwang/pageviews/searchpage/searchcellmodel -flaiwang/pageviews/searchpage/searchmsglistpage -flaiwang/pageviews/sharedpage/cells -flaiwang/pageviews/sharedpage/usercontrols -flaiwang/pageviews/sharemsgpage/usercontrols -flaiwang/sdk/internalsdk/internalmodel -flaiwang/sdk/internalsdk/internalservice -flaiwang/sdk/lwfileuploadmanager/lwprogressobservercenter -flaiwang/sdk/lwhostservice/biztasks -flaiwang/sdk/lwhostservice/utils -flaiwang/sdk/lwshareto/sharemodule -flaiwang/sdk/lwshareto/shareres -flaiwang/sdk/lwshareto/shareservice -flaiwang/sdk/viewmodels/friends -flaiwang/sdk/viewmodels/knock -flaiwang/sdk/viewmodels/others -flaiwang/usercontrols/lwprogressview/dacircularprogress -flaiwang/usercontrols/qbimagepicker/lwqbimagepicker+external -flaiwang/utils/lwfav/core -flaiwang/utils/lwfav/images -flaiwang/utils/lwfav/libs -flaiwang/utils/lwfav/ui -flaiwang/utils/lwmusic/xiamisdk -flaiwang/utils/nsstringadditions/nsstring_html -flaiwang/utils/ut/sinaweibo.bundle -flaiwang/integration/lwservice/ios/lwservice -flaiwang/pageviews/eventpage/eventcommon/attachmentview -flaiwang/pageviews/eventpage/eventcommon/comment -flaiwang/pageviews/eventpage/eventsearch/lwbubbleview -flaiwang/pageviews/eventpage/eventsearch/lweventsearchcell -flaiwang/pageviews/eventpage/eventwall/eventsignin -flaiwang/pageviews/knockpage/browse/knockfliptransition -flaiwang/pageviews/knockpage/browse/lwknocklocationmanager -flaiwang/utils/lwfav/libs/cdclient -flaiwang/utils/lwfav/libs/file_hash -flaiwang/utils/lwfav/libs/ghkit -flaiwang/utils/lwfav/libs/popoverview -flaiwang/utils/lwfav/ui/views -flaiwang/utils/lwmusic/xiamisdk/classes -flaiwang/utils/ut/sinaweibo.bundle/images -flaiwang/integration/lwservice/ios/lwservice/laiwangrpc -flaiwang/utils/lwmusic/xiamisdk/classes/player -f/users/henshao/ilaiwang/laiwangv3/laiwang -filelist /users/henshao/library/developer/xcode/deriveddata/laiwang-fxscnxkslrypubbeazdfkveysldy/build/intermediates/laiwang.build/debug-iphoneos/laiwang.build/objects-normal/arm64/laiwang.linkfilelist -dead_strip -objc -lcng -lg711 -lg729 -lpods-amap3dmap -lpods-amapsearch -lpods-cocoaasyncsocket -lpods-deviceprint -lpods-flex -lpods-httpdns -lpods-jdstatusbarnotification -lpods-jsonkit -lpods-lwcomponentkits -lpods-lwgpuimage -lpods-lwgraffiti -lpods-lwhttpdnsinterceptor -lpods-lwimageassets -lpods-lwimagefilter -lpods-lwjsonkit -lpods-lwnetworkkit -lpods-lwplugin -lpods-lwsharekit -lpods-lwxiamimusic -lpods-mjrefresh -lpods-mtopsdk -lpods-njkwebviewprogress -lpods-openudid -lpods-plcrashreporter -lpods-pstcollectionview -lpods-qupaisdk -lpods-reachability -lpods-regexkitlite -lpods-sdwebimage -lpods-securityguardsdk -lpods-speechrecognizer -lpods-tbmstore -lpods-tbscanlib -lpods-tbsecuritysdk -lpods-tbshorturl -lpods-thlabel -lpods-tencentopenapisdk -lpods-usertrack -lpods-voipsdk -lpods-ziparchive -lpods-crossplay -lpods-huoyansdk_laiwang -lpods-libextobjc -lpods-libwebp -lpods-lwsdk -lpods-mtopext -lqupaisdk -laudio_coding_module -laudio_conference_mixer -laudio_decoder_interface -laudio_device -laudio_encoder_interface -laudio_processing -lavcodec -lavformat -lavutil -lbitrate_controller -lc++ -lcommon_audio -lcommon_video -lfield_trial_default -lisac -lisacfix -licucore -lmedia_file -lmetrics_default -lneteq -loffset -lopus -lpaced_sender -lrbe_components -lred -lremote_bitrate_estimator -lrtc_base_approved -lrtc_sound -lrtp_rtcp -lsqlite3 -lsrtp -lstdc++ -lstdc++.6.0.9 -lswscale -lsystem_wrappers -ltbconf -lvideo_coding_utility -lvideo_engine_core -lvideo_processing -lvideo_render_module -lvideo_render_module_impl -lvideo_render_module_internal_impl -lvoice_engine -lwebrtc -lwebrtc_common -lwebrtc_h264 -lwebrtc_i420 -lwebrtc_opus -lwebrtc_utility -lwebrtc_video_coding -lx264 -lxiamimusic -lxml2 -lyuv -lyuv_neon -lz -framework amapsearchkit -framework avfoundation -framework audiotoolbox -framework cfnetwork -framework corefoundation -framework coregraphics -framework corelocation -framework coremedia -framework coretelephony -framework coretext -framework crashreporter -framework deviceprint -framework foundation -framework glkit -framework imageio -framework mamapkit -framework mobilecoreservices -framework mtopsdk -framework opengles -framework quartzcore -framework security -framework securityguardsdk -framework speechrecognizer -framework systemconfiguration -framework tbscanlib -framework tbsecuritysdk -framework tbshorturlresolve -framework tencentopenapi -framework uikit -framework ut -framework huoyan -framework mtopext -weak_framework adsupport -lstdc++ -objc -fobjc-arc -fobjc-arc -fobjc-link-runtime -miphoneos-version-min=6.0 -framework localauthentication -framework gamekit -framework addressbookui -framework accelerate -lstdc++.6.0.9 -lxml2 -framework mediaplayer -framework glkit -lz -framework systemconfiguration -framework coretelephony -framework security -framework messageui -framework audiotoolbox -framework mobilecoreservices -framework imageio -framework quartzcore -lsqlite3 -lz.1.2.5 -lresolv -liconv -framework alipaysdk -licucore -framework opengles -framework mapkit -framework cfnetwork -framework addressbook -framework assetslibrary -framework avfoundation -framework coreaudio -framework coredata -framework sharesdk -framework corelocation -framework coremedia -framework corevideo -framework coregraphics -framework uikit -framework foundation -lpods -xlinker -dependency_info -xlinker /users/henshao/library/developer/xcode/deriveddata/laiwang-fxscnxkslrypubbeazdfkveysldy/build/intermediates/laiwang.build/debug-iphoneos/laiwang.build/objects-normal/arm64/laiwang_dependency_info.dat -o /users/henshao/library/developer/xcode/deriveddata/laiwang-fxscnxkslrypubbeazdfkveysldy/build/products/debug-iphoneos/laiwang.app/laiwang

常用的工具如下。

find,查找文件。比如我想分析一下来往源代码各个部分的文件数量。可以发现业务里面文件数量最多的三个业务分别是扎堆、敲门和聊天。

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
[~/ilaiwang/laiwangv3/laiwang/pageviews]$ find . -maxdepth 1 -type d -print0 | xargs -0 -i {} sh -c 'echo $(find {} -type f | wc -l) {}' | sort -nr
914 .
167 ./eventpage
92 ./chatpage
91 ./knockpage
88 ./friendpage
86 ./pubaccountpage
54 ./feedpage
47 ./sharedpage
44 ./postpage
29 ./searchpage
29 ./photoeditorpage
29 ./morepage
28 ./nearbypage
26 ./friendradarpage
15 ./loginpage
14 ./minepage
14 ./albumpage
12 ./photofilterpage
10 ./emotionboxpage
9 ./sharemsgpage
8 ./xiamipage
8 ./notificationpage
4 ./introducepage
2 ./oauthpage
2 ./newguidepage
2 ./musicpage
2 ./moviepage
2 ./discoveryexpage

grep,搜索文本。结合正则表达式,分析日志什么的,非常之强大。grep有几个有用的选项,分别是“-r”递归搜索目录;“-i”,忽略大小写;“-c”,统计符合搜索条件的文本的行数;“–color”,高亮搜索结果。

du,统计目录大小。比如我想知道来往图片资源的情况。可以看出图片资源一共有8.2mb,其中共享的图片占到2.1mb,其次是聊天的图片占了1.4mb。

 

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
[~/ios_release/lwimageassets]$ du -sh lwimageassets
8.2m  lwimageassets
 
[~/ios_release/lwimageassets/lwimageassets]$ du -sh * | sort -hr
2.1m  shared_img
1.4m  chat_img
636k  event_img
528k  icon_default
524k  feed_img
472k  post_img
464k  knock_img
392k  radar_img
284k  profile_img
264k  friend_img
236k  pub_account_map_img
140k  editor_img
132k  yifa_img
132k  emotion_img
84k  neighbour_img
80k  lwuikits_img
76k  discovery_img
72k  graffiti_img
72k  asr_img
60k  login_img
52k  video_guide_img
44k  qr_img
40k  more_img
36k  share_msg_img
32k  my_img
20k  slide_img
16k  animal_img
12k  xiamibar_img
4.0k  search_img
4.0k  movie_img

file,用于查看文件信息。

?
1
2
3
4
5
6
7
8
9
$ file libxiamimusic.a
libxiamimusic.a: mach-o universal binary with 4 architectures
libxiamimusic.a (for architecture armv7):  current ar archive random library
libxiamimusic.a (for architecture i386):  current ar archive random library
libxiamimusic.a (for architecture x86_64):  current ar archive random library
libxiamimusic.a (for architecture arm64):  current ar archive random library
 
$ file laiwang
laiwang: mach-o 64-bit executable

strings,查看文件中的文本信息。

?
1
2
3
4
5
6
7
8
9
10
11
$ strings laiwang | head -n 10
ksearchtextkey
ksearchedpersonkey
invalid_token
user_in_black_list
user_blocked
expired_token
invalid_grant
refreshed_token
client_id
client_secret

nm,查看可执行程序里面的符号信息。

?
1
2
3
4
5
6
7
8
9
10
11
$ nm laiwang | head -n 10
00000001001425e4 t +[abcontact addresswithstreet:withcity:withstate:withzip:withcountry:withcode:]
0000000100142484 t +[abcontact arrayforproperty:inrecord:]
0000000100146438 t +[abcontact contactwithdata:]
000000010014591c t +[abcontact contactwithdictionary:]
000000010014191c t +[abcontact contactwithrecord:]
0000000100141984 t +[abcontact contactwithrecordid:]
0000000100141b70 t +[abcontact contact]
000000010014252c t +[abcontact dictionarywithvalue:andlabel:]
0000000100141c50 t +[abcontact localizedpropertyname:]
00000001001424e8 t +[abcontact objectforproperty:inrecord:]

vim

做简单的文本编辑和分析,vim是非常方便的。最简单有用的配置如下。在home目录下创建.vimrc隐藏文件,把下面的内容拷贝进去即可。

?
1
2
3
4
syntax on #支持语法高亮,看源代码文件会很舒服。
 
set hls #使用 / 查找内容的时候,会高亮字符串。
set ic #搜索的时候忽略大小写

cocoapods

cocoapods的源都安装在”~/.cocoapods/repos”目录下,有时候找不到pod、版本有问题、或者想确定一下pod的信息,都可以来这个地方翻一翻。

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
[~/.cocoapods/repos]$ ls
tbmainclientspecs/ alibaba/ master/
[~/.cocoapods/repos]$ ls tbmainclientspecs/
ampsdk/          tbcalendar/       tblogincenter/     tbscancode/     tbweitao/
accssdk/         tbcalendarservice/    tbloginservice/     tbscancodeservice/ tbweitaoservice/
 
[~]$ pod search swiftyjson
 
-> aiswiftyjson (1.0.6)
  aiswiftyjson makes it easy to deal with json data in swift .
  pod 'aiswiftyjson', '~> 1.0.6'
  - homepage: https://github.com/asiainfomobile/aiswiftyjson
  - source:  git@mirror.git.alibaba-inc.com:asiainfomobile/aiswiftyjson.git
  - versions: 1.0.6, 1.0.3 [master repo]
 
-> swiftyjson (2.3.2)
  swiftyjson makes it easy to deal with json data in swift
  pod 'swiftyjson', '~> 2.3.2'
  - homepage: https://github.com/swiftyjson/swiftyjson
  - source:  git@mirror.git.alibaba-inc.com:swiftyjson/swiftyjson.git
  - versions: 2.3.2, 2.3.1, 2.3.0, 2.2.1, 2.2.0, 2.1.3 [master repo]

sqlite

mac自带了sqlite命令行工具。小工具用起来很快很方便。所以简单介绍一下怎么使用这个工具。其实”.help”讲得很详细啦。

?
1
2
3
4
5
6
7
8
9
10
11
12
[~/downloads]$ sqlite3 laiwang.sqlite3
sqlite version 3.8.5 2014-08-15 22:37:57
enter ".help" for usage hints.
sqlite> .tables
lw_messages      lw_session_event_post
lw_offline_post2    lw_sessions    
sqlite> .schema lw_sessions
create table lw_sessions (primarykey integer primary key autoincrement, sessionid text, userid text, title text, icon text, content text, sourcetype text, data blob, actiontype text, actioncontent text, senderid text, settings blob, unreadcount integer, pushennabled integer, lastmodify text, ancientstampindb text, recentstampindb text, sortindex integer, background text, members blob);
create unique index idx_sessions_siduidst on lw_sessions(sessionid, userid, sourcetype);
create index idx_sessions_uidstsilm on lw_sessions(userid, sourcetype, sortindex, lastmodify);
sqlite> select * from lw_sessions limit 1;
1|2651304|2921438|新浪新闻|http://i01.lw.aliimg.com/tfs/t1vldnffxbxxbknnzjlaiwangtebus_73957a0c_180_180.60x60.jpg||pubmessage|||{"type":""}|||0|0|1429026489000|||0||

python simplehttpserver

simplehttpserver模块绝对是python最有用的一个模块(另外一个可能是json)。一个命令就能启动一个web服务器,做演示或者mock接口,不要太方便了。

?
1
2
[~]$ python -m simplehttpserver 9876
serving http on 0.0.0.0 port 9876 ...

nomad houston

nomad houston这个工具支持在命令行下给app推送信息,感觉蛮不错的。

以上就是写给ios程序员的命令行使用秘籍,认为不错的朋友收藏起来吧!

标签:

相关文章

热门资讯

2020微信伤感网名听哭了 让对方看到心疼的伤感网名大全
2020微信伤感网名听哭了 让对方看到心疼的伤感网名大全 2019-12-26
Intellij idea2020永久破解,亲测可用!!!
Intellij idea2020永久破解,亲测可用!!! 2020-07-29
背刺什么意思 网络词语背刺是什么梗
背刺什么意思 网络词语背刺是什么梗 2020-05-22
歪歪漫画vip账号共享2020_yy漫画免费账号密码共享
歪歪漫画vip账号共享2020_yy漫画免费账号密码共享 2020-04-07
苹果12mini价格表官网报价 iPhone12mini全版本价格汇总
苹果12mini价格表官网报价 iPhone12mini全版本价格汇总 2020-11-13
返回顶部