I am new to UNIX commands. I am trying to list the number of different years of all files in /etc based upon each files modification date(year).
I am playing around with variations of:
ls -lt /etc | sort | uniq -c
I realise that this only counts each unique file. I want to list the different years.
Can anyone help guide me in the right direction? Thanks.
Try this
ls -lT * | awk ' { print $9 }' | sort | uniq -c
Mac
ls -lT * | awk ' { print $9 }' | sort | uniq -c
Linux
ls -l --time-style +"%Y" * | awk ' { print $6 }' | sort | uniq -c
I have four windows called PP1, PP2, PP3, and PP4. I would like to join them so that they would look something like this:
-----------------
| | | | |
|PP1|PP2|PP3|PP4|
| | | | |
-----------------
Currently I'm using join-pane, but I am unsure of how to make them evenly spaced.
tmux join-pane -h -s PP2 -t PP1
tmux join-pane -h -s PP3 -t PP1
tmux join-pane -h -s PP4 -t PP1
I've also tried adding this to the end of the script, but to no avail:
tmux select-layout -t PP1 even-horizontal
Using the keyboard, you can press your activation key (Ctrl + B by default) and then press Alt + 1. Alternatively, repeated Ctrl + B, Space will cycle through the common layout options.
I realize that reshaping pane layout in general is not trivial to describe, but I'm interested in at least being able to swap the layout of two adjacent panes.
Suppose I've got these panes laid out like this
_____________
| | |
| | 2 |
| |________|
| 0 | |
| | |
| | |
| | 3 |
|____| |
| 1 | |
|____|________|
And I now discover that I want even more vertical space with pane 3. It's clearly not trivial to consider how I could rearrange it with pane 0 or 1 but it would be really nice if I could tell 3 and 2 to flip splitting axis:
_____________
| | | |
| | | |
| | | |
| 0 | | |
| | 3 |2 |
| | | |
| | | |
|____| | |
| 1 | | |
|____|_____|__|
(note here tmux will most likely reorder it so the old 3 becomes the new pane #2)
Currently when I try to run join-pane -h to reorganize it it tells me "cannot join pane to its own window". Yeah, well, I'm just trying to shuffle it without disrupting the entire layout.
I guess a workaround is to break it out to its own named window and then immediately join it back, though it looks like it won't be able to determine the orientation to switch to (horizontal vs vertical).
Note this is different from the operation of swapping the locations of two panes, for which there exists a command ready to use. I'm looking to swap the splitting axis.
Prefix + Space is bound to next layout
# Here is a jewel of a bind which does the task of flipping the
# orientation of the current pane with the pane before it (in the
# ordering) -- I had a SO question on this and nobody answered.
bind -n M-f move-pane -t '.-'
bind M-f move-pane -t '.-'
bind -n M-r move-pane -h -t '.-'
bind M-r move-pane -h -t '.-'
The comment is a lie, this functionality is not intuitive and frankly sucks, but it does work in a pinch.
Update: I have since updated this to remove the -n binds in my config, basically you do want to leave open the ability to "pass through" the keystroke through tmux. For example after a while I desired the same exact functionality inside Vim, which I bound to the same combination.
UPDATE: Can combine with the great solution here: https://stackoverflow.com/a/70024796/340947
This allows you to grab a pane and walk it all around. Makes my binds obsolete but both could be kept (like I will) for the familiar behaviors. I don't really like that mine will do something confusing if you happen to run it on the first pane ('.-' would pick the bottom right pane in this case).
C-b space (bound to next-layout by default) cycles through available layouts
#flipping the orientation of the current pane with the pane <arrow-way>-of
bind -n S-Up move-pane -h -t '.{up-of}'
bind -n S-Right move-pane -t '.{right-of}'
bind -n S-Left move-pane -t '.{left-of}'
bind -n S-down move-pane -h -t '.{down-of}'
here are my example to change the otiantation with the pane in the way of the arrow only Press Shift and Arrow-key or rebind the command how you want
If you really want to do exactly what you said, I would recommend breaking the pane out to a new window, then joining it back in.
For example...
Make sure you have one of the two panes active and break it out:
prefix break-pane
Go back into the main window (prefix w) and Perform any operations on the remaining panes to get it to the layout you want
Make sure you have the pane active you want the other pane to come in adjacent to
Make sure window is named (or assigned name is known)
Go to the new window that pane was broken out into (prefix w again)
join-pane -t <Main Window Name> -h (or -v if you want a vertical split)
To reiterate:
You have panes
laid out like
this:
_____________ _____________
| | | | | | |
| | 2 | | | | |
| |________| | | | |
| 0 | | but you want | 0 | | |
| | | them to look | | 3 |2 |
| | | like this: | | | |
| | 3 | | | | |
|____| | |____| | |
| 1 | | | 1 | | |
|____|________| |____|_____|__|
Since you know all the pane numbers (particularly the pane numbers of the panes you want to rearrange), the short answer is to type:
CTRL+B :move-pane -s 3 -t 2 -h ENTER
But if you don't know all the pane numbers, here is a simple way to reposition a pane:
If your mouse support is not already turned on, turn it on with:
CTRL+B :set-option -g mouse on ENTER
Using your mouse, click on the pane that you want to tear off -- that is, click on the pane that you want to reposition to be to the right or below another pane. (In your example, this will be pane 2, because you want to tear it off an reposition it to the right of pane 3.)
Next, click on the pane to which you want to attach/reposition the torn-off pane. (In your example, this will be pane 3, as you want to attach pane 2 to the right of it.)
Finally, type:
CTRL+B :move-pane -s ! -h ENTER
Explanation:
The magic is mostly happening in step 4, with the -s ! switch. It tells tmux to move the next-to-last pane you clicked on to the last pane you clicked on.
The -h switch in step 4 tells tmux to reattach the pane horizontally -- that is, to the right. If you want to attach it below, either use the -v switch instead, or leave out the -h switch altogether.
Notes:
These steps will place pane 2 to the right of pane 3. If you want pane 2 to the left of pane 3, then simply run through the steps with pane 3 as the "tear-off" panel, and pane 2 as the panel to attach to. (Or you can swap the panels; you can read through man tmux to figure out how.)
If you run step 4 via the Unix shell prompt, remember to quote the !, like this:
tmux move-pane -s '!' -h
The line:
set-option -g mouse on
is a great line to put inside your ~/.tmux.conf file, if you don't already have it in there.
As you said above, tmux will assign new pane numbers after you reorder them.
To see the pane number of a particular pane, click on the page you want (to make it current), and type:
CTRL+B i
If the status message that shows you the pane number disappears too fast for you, you can lengthen the time it is visible with:
CTRL+B :set-option -g display-time 4000 ENTER
To quickly see the pane number/index of all the panes, type:
CTRL+B Q
If the pane numbers disappear too fast for you, you can lengthen the time they are visible with:
CTRL+B :set-option -g display-panes-time 4000 ENTER
Combine your prefix (usually crtl+b) and then space.
When you have 2 panes, it will switch between horizontal to vertical mode.
I have a main autosys box (first_start_main_job)that has 2 different sub box.
When I enter autorep -j first_start_main_job -d I get something like:
JOb Name | Last Start | Last Run | ST | RUN | Pri/Xtx
first_start_main_job | some_time | some_time | SU | some_text
first_start_sub_job | some_time | some_time | SU | some_text
second_start_sub_job | some_time | some_time | SU | some_text
I just want ST(status) of first_start_main_job and store that in a variable.
Please let me know how to accomplish this.
Thanks in advance..
Use the print level switch -L, with level 0, (zero) to list only the outermost box. Then use your favorite script tool to get and store the ST value.
For example:
autorep -J main_job_box -d -L0
man autorep from a AutoSys command prompt will give you more information if you need it.
Just adding up to above posted answer.
To get the Status of Job in a variable we can filter out the status using awk.
e.g.
autorep -J first_start_main_job -d -L0 | awk '/SU /{print $6}'
It will check for the first line and if it contains "SU ", than the status will be printed.
im compressing a stylesheet into 1 line, using
cat stylesheet.css | gsed "s|/\*\(\\\\\)\?\*/|/~\1~/|g" -e "s|/\*[^*]*\*\+\([^/][^*]*\*\+\)*/||g" -e "s|\([^:/]\)//.*$|\1|" -e "s|^//.*$||" | tr '\n' ' ' | sed -e "s|/\*[^*]*\*\+\([^/][^*]*\*\+\)*/||g" -e "s|/\~\(\\\\\)\?\~/|/*\1*/|g" -e "s|\s\+| |g" -e "s| \([{;:,]\)|\1|g" -e "s|\([{;:,]\) |\1|g"
im trying to reverse the process.
cat stylesheet-compress.css | gsed 's/\([;{]\)\([^\n]\)/\1\n\t\2/g' | gsed 's/\([^}]\)}/\1;\n}\n\n/g' | gsed 's/{/ {/g' | gsed 's/[,]/& /g' | gsed '/}/ { n;n; s/}\n\([^\n]\)/}\n\n\1/ }'
works for the most part but some of the css entries have indenting and extra ;'s
I think you're looking for a CSS formatter. There are lots of them online. E.g. http://www.lonniebest.com/FormatCSS/. If you have to do it from shell, I'd spawn to another program to do the heavy lifting. http://cthedot.de/cssutils/ will do the trick.