Tag Info

New answers tagged

0

In man bash we can read in Shell Builtin Commands section: Unless otherwise noted, each builtin command documented in this section as accepting options preceded by - accepts -- to signify the end of the options. The :, true, false, and test builtins do not accept options and do not treat -- specially. The exit, logout, break, continue, let, and ...


0

I found a solution to my question on another stack exchange site: enter link description here Basically, I ssh from my mac into my Pi and send my arecord and lame command to the Pi. I then pipe stdout to mplayer (or anything really) via the command line. ssh pi@ip_of_pi "arecord --buffer-time=5000000 -D plughw:1,0 -f cd -t raw | lame -r - " | mplayer -


6

On a GNU system you'll need to use sed or similar if your locale uses multibyte characters (as jimmij suggests) because GNU tr can only reference a character per byte. In an ASCII locale you can remove all duplicates w/ tr like: LC_ALL=C tr -s '\0-\255' <input So... echo Thhiisss iisss mmyyy nameeee| LC_ALL=C tr -s '\0-\255' ...prints... This is my ...


10

With tr: echo "Thhiisss iisss mmyyy nameeee" | tr -s 'a-z'


2

Try tr: echo "Thhiisss iisss mmyyy nameeee" | tr -s 'hismye'


6

One way with sed: sed ':X;s/\(.\)\1/\1/g;tX' or even simpler: sed 's/\(.\)\1*/\1/g' (thanks Costas and mikeserv for comments).


0

see comparison of text editors , do an intersection between "right-to-left and bidirectional text" and "text shell integration" . :set lefttoright for vim . see documentation and this question . -- emacs generally can autodetect language and do the corresponding layout , on a per paragraph basis . see documentation .


-1

This worked for me on Ubuntu sudo apt-get install language-pack-en-base sudo apt-get install language-pack-ar-base sudo locale-gen en sudo locale-gen ar Then edit (i used vim) /etc/default/locale or /etc/environment to contain just the following LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8 Finally sudo dpkg-reconfigure locales These steps will give you ...


1

Your drive is formatted using extended and logical partitions. The MBR partition table format allows only 4 primary partitions, so /dev/sda1 - /dev/sda4 are reserved for primary and extended partitions. If you want more than 4 partitions, then you have to use logical partitions within an extended partition. In your case: /dev/sda1 is a primary partition ...


5

If your shell supports the ksh ${var/search/replace} form of parameter expansion (ksh93, zsh, mksh, yash, bash): for r1 in *R1*; do r2=${r1/R1/R2} singles=${r1/R1/singles} trimmed1=trimmed$r1 trimmed2=trimmed$r2 sickle pe -f "$r1" \ -r "$r2" \ -o "$trimmed1" \ -p "$trimmed2" \ -s "$singles" done POSIXly, you could do ...


0

Assuming I understand what you're looking for, you could solve it using awk: #!/bin/bash for file in *_R1_*; do file=`basename $file` newFile=`echo $file | awk -F '_R1_' '{print $1}'`_R2_`echo $file | awk -F '_R1_' '{print $2}'` sName=`echo $file | awk -F '_R1_' '{print $1}'`_singles_`echo $file | awk -F '_R1_' '{print $2}'` echo $newFile ...


3

It means that grep should search for ABC string only at the beginning of the line OR after space, moreover this string has to end with another space OR the end of the line. In other words someone wanted to search for a strings which form whole words. However this regexp has many issues, namely there could be many other characters before and after word (at ...


1

You have to do unset MAILCHECK. From the bash manual: MAILCHECK Specifies how often (in seconds) bash checks for mail. The default is 60 seconds. When it is time to check for mail, the shell does so before displaying the primary prompt. If this variable is unset, or set to a value that is not a number ...


1

Have a look at lnav, an advanced log file viewer.


0

For those who prefer w3m (vi style bindings): pandoc file.md | w3m -T text/html I put it in a script, mdview.sh, and put that in my path: #!/bin/sh pandoc $1 | w3m -T text/html


1

ls by itself, with no options or anything, will "list the current directory." By default, "listing a directory" refers to the files that are contained in it. The -d flag changes ls not to list the files within the specified directory, but to list the information about the directory itself. It is not, as you mistakenly thought, referring to "directories in ...


2

ls -d shows information about a directory or symbolic link - with this information being (in simple terms) it's respective path. The logical assumption is that the d stands for directory, since it's most basic definition in UNIX terminology I've come across is 'lists directories'. This can seem on the surface to not be that useful; say you currently reside ...


2

Not sure about the terminology but ls -d just lists info about the thing that follows and nothing more, ie it does NOT expand directory lists, so: ls -ld /usr/bin will just give you one line of output about /usr/bin itself. And ls -ld * will just give you info about each file or directory in the pwd but won't also expand any of the directories to ...


1

Double-quote your variables. Double-quote your variables. Double-quote your variables. filename=$(date +'%d %b %Y') && tail -n1 "$filename"


2

There is a partial answer here: The command to use is 'gsettings` and the actual settings to use you can find by using: dconf watch / in the terminal, while you adjust the settings. You get a bunch of statements like this: /org/gnome/desktop/wm/preferences/theme 'elementary' /org/pantheon/desktop/gala/behavior/hotcorner-bottomleft 'custom-command' ...


2

With some sed implementations like GNU's or FreeBSD's: sed 's/foo/bar/i' ./* The i makes what you need. If your sed doesn't support that non-standard extension, you can always do: sed 's/[fF][oO][oO]/bar/' ./*


0

You should use domain from your realm,not ekiga You can troubelshoot by using asterisk -r sip set debug on


2

Check the bash manual: When bash is interactive, in the absence of any traps, it ignores SIGTERM https://www.gnu.org/software/bash/manual/bashref.html#Signals Check the kill help text (help kill at a bash prompt): If neither SIGSPEC nor SIGNUM is present, then SIGTERM is assumed. ...


2

You can, but the shell tries hard not to die unless it's absolutely sure that's what is required. SIGHUP works (as does SIGKILL), and you can try this - kill -HUP $$ (If you prefer numeric signal identifiers the HUP can be replaced with 1.) The reason that SIGHUP works is that this is the signal that would have been sent when a serial line connection ...


0

The special parameters "$*" and "$@" refer to every argument in the shell's argument array each in different ways. "$@" - this parameter is how you refer to the shell array as a list of strings. With this you can expand a faithful reproduction of the argument array for handing off to another command. The expansion of "$@" can also be added to at either ...


1

From man bash: Special Parameters The shell treats several parameters specially. These parameters may only be referenced; assignment to them is not allowed. * Expands to the positional parameters, starting from one. When the expansion is not within double quotes, each positional parameter expands to a separate word. ...


0

Special Parameters $* and $@: There are special parameters that allow accessing all of the command-line arguments at once. $* and $@ both will act the same unless they are enclosed in double quotes, "". Both the parameter specifies all command-line arguments but the "$*" special parameter takes the entire list as one argument with spaces between and the ...


1

Amongst other things: "$*" expands to "arg1 arg2 arg3 …" "$@" expands to "arg1" "arg2" "arg3" … Thus "$@" is safer. $* may be older, existing for backwards compatibility.


0

This is all about how arguments separators (by default spaces) are handled: "$@" will expand to a sequence of strings, while "$*" will expand to a single string. Take the example script "test.sh" below: #$/bin/sh for i in "$*"; do echo $i done echo "====" for i in "$@"; do echo $i done When called with 4 args invoked like this: ./test.sh 1 2 3 "4 ...


3

The simple primitive explanation is: $* all set arguments is one string (arguments are separated by the first character in $IFS) $@ each argument is different string (arguments are separated by newline) From man bash: * Expands to the positional parameters, starting from one. When the expansion is not within dou‐ ble quotes, each positional ...


1

The difference lies in the way the two variables are expanded. $@ expands so that each argument is separated by a \0NUL and seen individually. Thus, given foo arg1 arg2 arg3, $@ will become arg1\0arg2\0arg3. In particular, each argument is protected from splitting, so that, if arg1 were foo bar, unless further processing is done, it will be seen as foo bar ...


4

If you are in the company directory then try this: cp file1 sales cp file2 sales OR cp file1 sales; cp file2 sales Or cp file1 file2 file3 sales The last is the easiest and can accomplish copying all files it a single subdirectory in one line. If you want to complete the task and copy each file to each subdirectory in one line, merge the second and ...


2

Here are some suggestions: -- If she has started with basic math, she may like bc or python command prompt. -- You can write her a simple interactive, menu driven script to do counting or printing alphabets in fancy and colorful fonts. -- I recall I played a game called hangman a while ago. You can remove complicated words from the dictionary and add ...


2

You can use the command stat to see more metadata of the file/directory.


3

It could be that stardict-2.0.0-pre2.tar.gz and stardict-2.0.0.tar.gz are just not functional. I attempted to install both on CentOS 5.6 without success. The INSTALL and README are indeed empty on the pre2.tar.gz version. Unless you specifically need this version I recommend installing stardict-2.4.8.tar.bz2 instead. wget ...


3

Others have mentioned du, but I would also like to mention Ncdu -- which is an ncurses version of du and provides interactivity: You can explore the directory hierarchy directly and see the sizes of subdirectories.


4

You could use find + file and output the name of the files that have mime type image/jpeg: find . -type f -exec sh -c 'file --mime-type "$0" | grep -q image/jpeg && echo "$0"' {} \; or find . -type f -exec sh -c ' mt=$(file --brief --mime-type "$0") [ -z "${mt#image/jpeg}" ] && printf "$0\n" ' {} \;


6

As a start, you could print out files with a .jpg file extension with: sudo find / -name *.jpg -print See how that behaves, modify to suit, and you can then pipe the output into another function rather than just printout if you'd like. edit As mentioned in the comments below, this may be a better starting point for you: sudo find / -iname "*.jpg"


8

Just use the du command: du -sh * will give you the size of all the directories,files etc in current directory in human readable format. You can use the df command to know the free space in the disk: df -h .


4

The du command shows the disk usage of the file. The -h option shows results in human-readable form (e.g., 4k, 5M, 3G). du -h (file name)


0

I've used ls and ls -a but really should've used ls -al before asking the question. ls -al shows -rw-r--r-- 1 Jing staff 49630 27 Nov 11:02 drwxr-xr-x 9 Jing staff 306 19 Feb 09:32 .. drwxr-xr-x 3 Jing staff 102 19 Feb 09:46 ~ drwxr-xr-x 8 Jing staff 272 19 Feb 10:09 . drwxr-xr-x 15 Jing staff 510 19 Feb 00:49 .. drwxr-xr-x ...


0

If you have mc installed, use it


6

du is your friend. If you just want do know the total size of a directory then jump into it and run: du -hs If you also would like to know which sub-folders spend how much disk space?! You could extend this command to: du -h --max-depth=1 | sort -hr which will give you the size of all sub-folders (level 1). The output will be sorted (largest folder on ...


1

You didn't create ..; that entry always exists in every directory and refers to the parent directory. You may want to check the parent directory for extra files. To refer to ~, you can put it in quotes to prevent the shell from expanding it: "~".


20

du -sh is a good place to start. The options are (from man du): -s, --summarize display only a total for each argument -h, --human-readable print sizes in human readable format (e.g., 1K 234M 2G) To check more than one directory and see the total, use du -sch: -c, --total produce a grand total


0

Though all of the suggestions work well I've found my alternative is to use screen, a program that sets up a virtual terminal on your screen. You might consider starting it with screen -S and then a sessionname.Screen can be installed on virtually all linux and unix derivatives. Hitting control a and c will start a second session. This would allow you to ...


0

You can try vim with AnsiEsc.vim plugin to view ANSI colors through escape codes, then redirect standard output to vim -, activate :syntax on and convert the file to html by vim command: :TOhtml. The generated html file should have coloured output. To convert source code non-interactively into html, try the following command: vim -E -s -c "let ...


0

This error happens when vim is invoked and it's connected to the previous pipeline's output, instead of the terminal and it's receiving different unexpected input (like NULs). The same happens when you run: vim < /dev/null, so reset command in this case helps. This is explained well by grawity at superuser. On Unix/OSX you can use xargs with -o ...


0

The simplest way is to pass locate as shell substitution, like: vim $(locate filename123) You can also consider to use find instead of locate to pass file names to edit, in example: find . -name 'filename123' -exec vim {} + On Unix/OSX you can use xargs with -o parameter, like: locate filename123 | xargs -o vim -o Reopen stdin as /dev/tty in the ...


0

If you want to possibly * remove everything then you can do your dd command; however, you'll still need to create a partition table. NOTE I'm going to use /dev/sdb because that is what you have in your original question I recommend fdisk. So you would do something like the following: # fdisk /dev/sdb Command (m for help): n Select (default p): p Partition ...



Top 50 recent answers are included