DEV Community

Discussion on: CLI for Efficiency #1

Collapse
 
ferricoxide profile image
Thomas H Jones II

You can collapse your two commands:

| grep kde | cut -d "/" -f 1 

Into one command:

| awk -F "/" '/-kde-/{ print $1 }'

Note: I set awk's search to the slightly longer -kde- (from your grep's kde) for more-precise targeting.

Similarly, if you really need your tr capability, you can subsume its use by switching up awk's outputer to printf (and using appropriate formatting-specification).