Tag Info

New answers tagged

0

This is not possible. There is no history of previous atime values kept in memory by the system. Well, to be completely honest, the previous atime value may exist somewhere on RAM or even on disk, but you wouldn't know where, nor for how long.


2

Options for compgen command are the same as complete, except -p and -r. From compgen man page: compgen compgen [option] [word] Generate possible completion matches for word according to the options, which may be any option accepted by the complete builtin with the exception of -p and -r, and write the matches to the standard output For options ...


4

!-2 More fun is available. Say you want to keep operating on a file (as above, where you're using test.py, repeatedly): cp foo.py thing.py edit $_ python $_ !-2 ^thing^foo Copy an existing file to thing.py Edit (vim, emacs - though why you'd be using a command line if you were running Emacs-OS, I have no idea) thing.py - the last word in the previous ...


4

You can use !-2: $ echo foo foo $ echo bar bar $ !-2 echo foo foo That may not help with your right-hand situation. You can also use !string history searching for this sort of case: $ python test.py $ vim test.py $ !py python test.py # Printed, then run This may be more convenient to use. It will run: the most recent command preceding the current ...


4

Someting like this worked for me: (tail -f /var/log/syslog | awk -W interactive '{printf "\033[1;31m%s\033[0m\n", $0}' & \ tail -f /var/log/auth.log | awk -W interactive '{printf "\033[1;32m%s\033[0m\n", $0}' & \ tail -f /var/log/Xorg.0.log | awk -W interactive '{printf "\033[1;34m%s\033[0m\n", $0}') Explanation: tail -f file: append data as ...


14

Using GNU grep for the colouring: color() { GREP_COLOR=$1 grep --color '.*'; } (tail -qf /var/log/syslog | color 31 & tail -qf /var/log/fail2ban.log | color 32 & tail -qf /var/log/nginx/error.log | color 33) Note that the first 2 are started in background. That means they won't be killed if you press Ctrl-C (shell explicitly ignore SIGINT for ...


2

With find and file: find Music/Albert\ Ayler/Vibrations/ -name "*.flac" -exec file {} \; Music/Albert Ayler/Vibrations/1.Ghosts.flac: FLAC audio bitstream data, 16 bit, stereo, 44.1 kHz, 5653620 samples Music/Albert Ayler/Vibrations/4.Ghosts (2).flac: FLAC audio bitstream data, 16 bit, stereo, 44.1 kHz, 21096264 samples Music/Albert Ayler/Vibrations/3.Holy ...


1

unzip -l file.zip/sub_file.zip doesn't work because file.zip isn't a directory: it's a regular file that happens to be in an archive format. But you can create a directory that mirrors the content of the zip file, by mounting a filesystem that presents a view of the content of the zip file. There are several choices, pick whichever is easiest to install on ...


1

With zsh: $ unzip -l a.zip.zip Archive: a.zip.zip Length Date Time Name --------- ---------- ----- ---- 195 2014-08-18 09:38 a.zip --------- ------- 195 1 file $ unzip -l =(unzip -p a.zip.zip a.zip) Archive: /tmp/zsh0i0JyZ Length Date Time Name --------- ---------- ----- ...


2

You can use less with Wolfgang Friebel's lesspipe script: less file.zip:sub_file.zip


0

You do $_. echo 'hey there' & echo "$_" OUTPUT hey there hey there


1

Here is a possible PCRE-based solution based on a similar question Search a pattern and print preceding lines starting with another pattern grep -zPo '.*abc.*(?=(?s)(?(?!abc).)*?xyz)' file will output the last line containing abc that occurs before each instance of xyz e.g. given a file 1 abc 2 abc 3 abc 4 abc 5 abc 6 bcd 7 cde 8 def 9 xyz 10 xyz then ...


2

tac LCSoap_8.log | sed -n ' /Server returned HTTP response code: 500 for URL:/,/qualified-src-dn=.*src-dn/!d s/.*qualified-src-dn=\(.*\)src-dn.*/\1/p' or to reuse your grep: tac LCSoap_8.log | sed ' /Server returned HTTP response code: 500 for URL:/,/qualified-src-dn=.*src-dn/!d' | grep -Po '(?<=qualified-src-dn=).*(?=src-dn)' sed '/A/,B/!d' ...


1

LESS uses several environment variables to control colors based on termcap library. The list of variable is the following: export LESS_TERMCAP_mb=$'\E[6m' # begin blinking export LESS_TERMCAP_md=$'\E[34m' # begin bold export LESS_TERMCAP_us=$'\E[4;32m' # begin underline export LESS_TERMCAP_so=$'\E[1;33;41m' # begin standout-mode - ...


0

chk='/[m]edia' for f in $chk/movies/file $chk/tv/file $chk/music/file do [ -z "${f##"$chk"*}" ] || printf %s\\n "$f exists!" done You can glob against a known value and check its results for resolution.


0

date -r almost does the job. All you need to do is shift the origin, which is an addition. date -r $((number_of_seconds - epoch)) where epoch is the number of seconds between 1 January 1 and 1 January 1970. The value of epoch depends on your calendar. In the Gregorian calendar, there are 477 leap years between 1 and 1970, so 365 * 1969 + 477 = 719162 ...


-1

I believe VirtualBox has an option to directly enable mounting of your physical DVD. Directly mounting won't work, because here Virtual Box needs to emulate ur DVD.


9

In a screen or tmux session, set up a shell that will reverse your changes after a delay. I don't know anything about iptables, so can't help with that, but something like this has saved my proverbial bacon on numerous occasions while altering live firewall configs on FreeBSD: # In one `screen` or `tmux` window % sleep 60 && <command to reverse ...


0

The problem is that not everyone agrees on what the pre-1923 dates are. We (westerners) are now using the Gregorian calendar. Before 1582, people were using the Julian calendar. In between 1582 and 1923, some people used one or the other. For instance, England switched to the Gregorian calendar in 1752 and that's what the cal command uses as the switching ...


1

You can use this: echo $(( `date +%s` - ` date --date=yesterday +%s ` )) 86400 You can replace 'yesterday' by any date. For example: echo $(( `date +%s` - ` date --date='Tue Aug 9 11:44:34 CEST 2014' +%s ` )) 259209 Tested on GNU/Linux.


0

An awk solution awk -vq='"' ' func csv2del(n) { for(i=n; i<=c; i++) {if(i%2 == 1) gsub(/,/, OFS, a[i]) else a[i] = (q a[i] q) out = (out) ? out a[i] : a[i]} return out} {c=split($0, a, q); out=X; if(a[1]) $0=csv2del(1) else $0=csv2del(2)}1' OFS='|' file


0

sed "s/'/'\\\\''/g;s/.*/\$* '&'/" <<\FILE |\ sh -s -- command echo --option all of the{&}se li$n\es 'are safely shell quoted and handed to command as its last argument following --option, and, here, before that echo FILE OUTPUT --option all of the{&}se li$n\es 'are safely shell --option quoted and handed to command as its last ...


3

You can do this with a quite simple Bash instruction: mytext="(123434): hello::{apple,orange,mango}." echo ${mytext#*)} This will print : hello::{apple,orange,mango}.. You can cut prefixes and suffixes in similar way. Moreover, prefix and suffix definitions can contain wildcards. Cut prefix - up to first prefix wildcard match: ${variable#prefix} Cut ...


4

You can use cut: echo '(123434): hello::{apple,orange,mango}.' | cut -d: -f2-


6

This sed command should do the trick. The following command will overwright the file: sed -i 's/^[^:]*:/:/' file To just print the output, remove the -i flag. To put the output in a new file, remove the -i flag and redirect the output: sed 's/^[^:]*:/:/' file > new_file


2

I have realized that the reason why /dev/dvd was not being read was because of a setting that I had turned off on VirtualBox. I experimented a little bit and was able to mount the drive after that point. The setting I had to turn on was the .iso file found in Devices, DVD/CD in VirtualBox. I turned it off earlier because it kept taking me to the ...


4

Another option is xargs. e.g. cat file | xargs -I{} -d"\n" command --option {} other args {} is the place holder for the line of text. I am using gnu xargs, on gnu+linux. Other xargs may not have all of the same features.


7

Use while read loop: : > another_file ## Truncate file. while IFS= read -r LINE; do command --option "$LINE" >> another_file done < file Another is to redirect output by block: while IFS= read -r LINE; do command --option "$LINE" done < file > another_file Last is to open the file: exec 4> another_file while IFS= read ...


1

There are a couple of ways, usermod is a good tool that comes to mind (I have trouble with it at times). Another is chfn this will generally give you a lot of options to change (phone number, office location, and other stuff). # chfn username should open your favorite editor for you to change things with. There are some unsafe methods, but I don't ...


5

sudo usermod -c "Jecht Tyre" jecht You can change it with -c option. -c is for adding comment usermod -c "YOUR NAME" username


1

crontab -e it will open a configuration file in editor and you then add your line to the end: * * * * * /usr/bin/sh t.sh


1

You may want to add -t FILESYSTEMTYPE, with FILESYSTEMTYPE being auto, ext4, ntfs or any other valid system type. Which gives you mount /dev/dvd /media -t auto, by example.


0

To actually just create a file, you can use touch with find: $ find . -type d -exec touch {}/file \;


0

You want to show hidden files/folders BUT . and .. ? Use this bash wildcard {.[!.]*,..?*} Sample Data You can try by generating sample data : $ touch ...a ...aa ..a ..aa .a .aa .aaa a $ mkdir ...b ...bb ..b ..bb .b .bb .bbb b Proof Below you can see the expected removed entries : $ diff <(\ls -a) <(\ls -ad {.[!.]*,..?*}) 1,3d0 ...


0

sed 's/||/| |/g;s/||/| |/g' filename-here | column -s"|" -t | less -#2 -N -S Explanation: Sed will add a space between blank delimters Column will add equal spacing between the columns zydsld|asl|asd das|aosdk|dd becomes zydsld|asl |asd das |aosdk|dd Less will open the output in a file viewer. -N and -S will add line number and disable wrapping ...


0

I managed to get this to work: cvlc -vvv --daemon --pidfile ./coffee_stream.pid rtsp://10.217.112.30:554/axis-media/media.amp?videocodec=h264 --sout="#transcode{vfilter=gradient{type=1},vcodec=theo,acodec=vorb,vb=800,ab=128}:standard{access=http{mime=video/ogg},mux=ogg,dst=:8091}"


0

I believe that you will find the limit you encounter is not the number of commands but the size of the sh command buffer. On current Linux systems I believe that the size is about 64K characters.


7

There isn't really; as long your computer's memory can handle the queue, the shell should do its best. According to POSIX: The shell shall read its input in terms of lines from a file, from a terminal in the case of an interactive shell, or from a string in the case of sh -c or system(). The input lines can be of unlimited length. These lines shall be ...


1

With ROOT, this is actually easy. Once the root program has read the files passed on the command line, it continues to read interactive commands (unless you pass the -q option). So you can pass your startup commands in an additional file parameter, via an extra file descriptor. #!/bin/sh ./runReader.py SummerStd 140PU_NM1 root -l ...


1

You could do: expect -c 'spawn -noecho root -l SummerStd_140PU_NM1_his.root send "TBrowser a;\r" interact'


1

As you found out, you can't disable a keyword with enable -n. However, you can make a keyword a builtin also with enable -f and then disable it: unpack the sources for your current version of bash ./configure && make In examples/loadables, you'll find a number of example loadable builtins, edit one of them, for instance the sync one to replace all ...


3

You can do: alias time='"time" ' (the trailing space is to allow alias expansion after it, as a bonus). Quoting a keyword (keywords being part of the shell language syntax) stops it from being interpreted as a keyword, so here, normal command look up is performed on it. It works in bash, zsh, mksh, but not ksh93, ash or yash. Note that for ...


-2

You can't disable it but you can hide it with a function. Use at own risk. shell_builtin() { : ## Do nothing. } To enable it back, simply unset it: unset shell_builtin


0

Ok, let's make it short: ls -1|xargs -i% bash -c 'mkdir %/doc;>>%/doc/doc1.txt' - We are on a directoy like your start directory. ls -11 lists herdir etc, one per line (there is nothing else) xarg runs a shell with a script argument, replacing the % by the directory For each directory: bash runs it's one string argument as a shell script, ...


8

In bash, use something like these lines: mkdir -p {mydir,hisdir,herdir}/doc touch {mydir,hisdir,herdir}/doc/doc1.txt The {...} syntax is called "brace expansion", and unlike pathname expansion, where the filename must exist, the generated results don't need to match anything already there. And the -p means create all nested components of the path as ...


0

for d in /*/ do [ -d "$d" ] || break f=$d/docs/doc1.txt mkdir -p -- "${f%/*}" touch -- "$f" done I think it meets your goals. Maybe I'm missing something though. Else you could: set -- /*/ [ -d "$1" ] && printf 'd=$%d mkdir -p -- "$d/docs" && touch -- "$d/docs/doc1.txt" ' $(seq "$#") | sh -s -- "$@" Or: set ...


5

With zsh: dirs=(*(/)) mkdir -- $^dirs/doc touch -- $^dirs/doc/doc1.txt (/) is a globbing qualifier, / means to select only directories. $^array (reminiscent of rc's ^ operator) is to turn on a brace-like type of expansion on the array, so $^array/foo is like {elt1,elt2,elt3}/doc (where elt1, elt2, elt3 are the elements of the array). One could also do: ...


1

In Ubuntu 12.04 with default gnome it is gnome-session-quit.


0

If you don't mind Perl: perl -053nE ' BEGIN{ $value = shift } chomp; tr {=:}{ }; %h = eval "qw($_)"; say $h{prop2} if $h{prop1} eq $value ' your_file value1 This doesn't assume any particular order of properties, but it does assume that neither property names nor values will contain spaces. If that's not true, some more parsing would ...



Top 50 recent answers are included