Tag Info

New answers tagged

5

Simple, when you “login” with a user the user’s default shell is executed. The passwd file contains this information (i.e. /bin/csh, /bin/bash, or the like). It is one of the fields in the file which is used. Below is an example entry: jsmith:x:1001:1000:Joe Smith,Room 1007,(234)555-8910,(234)555-0044,email:/home/jsmith:/bin/sh Notice the very last field ...


1

It seems you are using the Z Shell, at least the behavior you are describing is reproducible there: zsh$ echo $USERNAME user1 zsh$ USERNAME=test zsh$ echo $USERNAME user1 zsh$ The manpage zshparam gives the reason: USERNAME The username corresponding to the real user ID of the shell process. If you have sufficient privileges, you ...


0

USER and LOGNAME are addressed in envron(7) manpage. login(1) is the process who set these variables. both USER and LOGNAME variables can be modified and later access return the new value. find nowhere the reference for USERNAME, and this variable is not set in bash4.3. bash defines a UID readonly numerical variable. attempt to change this variable in bash ...


1

It isn't true that alias is used only to navigate folders. It can be used for other commands as well (that's why it's called alias). In example: alias arestart='sudo apachectl restart' alias alog='tail -f /var/log/apache2/error_log' and place them in ~/.bashrc or ~/.bash_profile. Or you may want to put all your alias definitions into a separate file ...


0

source command executes the provided script (executable permission is not mandatory) in the current shell environment, while ./ executes the provided executable script in a new shell. source command do have a synonym . filename. To make it more clear, have a look at the following script, which sets the alias. make_alias #! /bin/bash alias myproject='cd ...


0

Try findstr, it worse than grep, but it does work: findstr /i /m /r /c:":announce[0-9]*:http://your\.tracker\.com" *.torrent /i - Case-insensitive search /m - Print only the filename if a file contains a match /r - Use string as a regular expression /c:"string" - Use string as a literal search string


0

The clean solution was given by @Adaephon's answer, which I definitively recommend. However, I want to give you the cause of your troubles, too: The problems are resulting because zsh counts the escape codes to the length of the prompt. This is wrong, because these codes are processed by the terminal emulator and are not displayed and results in the offset ...


1

It seems that the ANSI codes are messing with your terminal, possibly due to some interactions with the other contents of PS1 or because you do not reset to default. Luckily, in zsh there is no need to use ANSI escape codes. You can use %F{color} and %K{color} to set foreground and background colors respectively and %f and %k to reset default values (See ...


-1

Try using the below: $ getent group "groupname" or probably this might also work $ awk -F':' '{ print $1 }' /etc/passwd


2

In bash and similar shells read -r; rm "$REPLY" then just type in the filename literally, \;:$"\', and press Enter. The read command reads a line from standard input and saves it to the variable REPLY. The -r flag tells it to read the line literally and not interpret backslashes as escape sequences. Quoting $REPLY ensures that the contents of REPLY will ...


1

You can use single quotes, and then you only have to worry about quoting the single quote itself. rm '\;:$"\'\' In interactive use, you could simply use tab completion, starting with '\ or \\. Tab completion from '\ yields '\;:$"\'\''', since bash simply replaces every embedded single quote with '\''. Tab completion from nothing or from \\ yields ...


0

I find it easiest in such cases to type/escape at most a few characters and then let bash complete the command with <TAB>: bash then makes sure to quote the stuff suitable for its own purposes. In this case, if I do touch '\;:$"\'\' rm \ <TAB> the completion for repeated <TAB> subsequently goes to rm \\ rm \\\\ rm \\\\\\\\ rm ...


1

If you are not limited to using bash or another shell script environment, an easy way to remove such a file would probably be to either write a short program that simply calls unlink() in your favorite language, or use a file manager such as Gnome Commander or Midnight Commander to delete the file manually. The latter option would allow you to select the ...


0

Try this, $ rm \\\;\:\$\"\\\' "\" is used as escape sequence in bash scripting which has a litral meaning.


11

If the files name is exactly \;:$"\', then you should be able to remove it with: rm \\\;\:\$\"\\\' Just ecape all the characters with a single \.


4

You can try ls -li in the directory containing the file and deleting the file with the inode returned by issuing find . -inum <inode-number> -exec rm -i {} \; I added the -i to the find command to prompt before deletion in case another file is found by the find command than you expect. In addition to the comment I tried to create and remove the file ...


0

ssh host 'ls -als' When you ask ssh to run a command on the remote system, ssh doesn't normally allocate a PTY (pseudo-TTY) for the remote session. You can run ssh with -t to force it to allocate a tty: ssh -t host 'ls -als' If you don't want to type that all the time, you could add this line to the ".ssh/config" file on your local host: RequestTTY yes ...


0

I couldn't find a thread that answers this question with my criteria, so here's my solution. important criteria a separate master history (no session can interrupt your history) automatic history writing (no hotkeys) infrequent writes (no appending after each command) a natural solution write this to ~/.bashrc: # append a session's history on shell ...


3

OK, for starters, I think you mean ps --pid and not ps ---pid. You don't need to echo $$ and then type the number into ps --pid number; it's good enough to type ps --pid $$.  Unless you're talking about # echo $$ 42 # su joe % ps --pid 42 in which case you're doing the right thing. What were you expecting? --pid pidlist Select by process ID.  ...


1

You can use a check in you ~/.bashrc if it is running in (u)rxvt. And if so, replace bash with zsh: if [[ "$TERM" == *rxvt* ]]; then exec zsh fi


1

It's not really completely different: you can use redirections with an command bash -c 'exec date > date.out' ; cat date.out Why not use it without a command bash -c 'exec > date.out; date' ; cat date.out


1

You can send zsh in as a command when launching urxvt: urxvt -e /path/to/zsh


1

I was looking to solve a problem like yours, and realized what I was really looking for was sshfs. Maybe you can use it too? My problem was that when ssh'ing, I wished to keep my colors, aliases, functions and scripts while working remote. http://fuse.sourceforge.net/sshfs.html


0

How about just: mv ./*/*.pdf . I've done a test on my computer (zsh 5.0.7 (x86_64-pc-linux-gnu)) and it worked perfectly: > ls -r * sub3: r.2 r.1 sub2: s.2 s.1 sub1: t.2 t.1 > mv ./*/*.pdf . > ls r.1 r.2 s.1 s.2 sub1 sub2 sub3 t.1 t.2 > tree . ├── r.1 ├── r.2 ├── ...


0

You could use find for this: find * -name "*.pdf" -maxdepth 1 -type f -exec mv {} ../ \; -name "*.pdf" means the pattern to match -maxdepth 1 means it will only go one level deep -type f means ignore everything that's not a file (includes symlinks, directories etc.) -exec mv {} ../ \; is the command to execute for each file found - to be specific, this ...


0

mv */*.PDF . That will expand to a list of all files with extension .PDF in all subdirectories one level deep, and move those to the current directory. A complication may arise if there are so many that you get the error argument list too long. In that case this will work, assuming there are no special characters like spaces, semicolons, quotes etc. in ...


0

If I read your question right, you're looking for something else than what chere supplies (which, granted, is pretty cool in its own right). The current version of Cygwin doesn't have an /etc/passwd file, and the system I'm working on has Windows account information in a domain database out of my control. Consequently, chsh is no longer supported. I ...


0

$ awk -F, 'NR>1 && /^[SMTWF]/{print sum;f=0} /^S/{print;sum=0;f=1;next} {sum+=$1$2} END{if (f)print sum}' file Sat 02/28/2015__19:32:37.63 600048 Sat 02/28/2015__19:37:38.41 475428 Sun 02/29/2015__16:32:40.11 600087 Sun 02/29/2015__16:32:49.20 475394 How it works -F, Use a comma for the field separator. NR>1 && /^[SMTWF]/{print ...


0

Check which shell you're using with this command: [source] ps -p $$ Then check your shell's documentation or use your favorite search engine to find out how that file is called. For the most widely used bash shell it's .bashrc or .bash_profile.


2

In addition to what said here you can simply use less instead of cat. It prompts if the file is not a regular one, and give some plus as, for example, the list of the files in a zip,rar archive... By the way you can use even cat -v that will transform non reading characters without adding a $ to the end of each line.


0

I really don't think this is worth it when you could just check before cating something, but you could set up a function in your ~/.bashrc to do this: cat(){ for i in "$@" do if file --mime "$i" | grep "charset=binary" >/dev/null then printf "File %s is binary, skipping\n" "$i" >&2 else ...


-1

Save this as a script for example newcat.sh, and make it executable: #!/bin/bash result=`file $1 | grep -c "binary"` if [ "$result" -gt 0 ] then echo "executable file" else cat $1 fi then use it as ./newcat.sh filename


2

If you call file with -i it will return the mime type allowing you to determine if it is text or not. file -i file.name | grep text/ && cat file.name if file.name is binary the && does not execute the cat and if its plain text then it does. This now matches script and other "text" files that are not marked as "plain"


0

I'm far from a python/pip expert, but I have used it for various purposes for several years and have yet to encounter a straight forward use of pip install that is interactive. It does have extensive options for less straight forward case (alternate package indices, caching, dev mode, etc,). If you have a specific install case that requires some ...


3

What do you need is to enable Backup and Restore privileges, granted by default to the Administrators group. One way to do that is to use this PowerShell script: Set-ExecutionPolicy Unrestricted Process Import-Module .\Set-LHSTokenPrivilege.ps1 Set-LHSTokenPrivilege SeBackupPrivilege Set-LHSTokenPrivilege SeRestorePrivilege With Backup and Restore ...


1

You can't. Even being SYSTEM you can't access files or other objects if you don't have permissions to do so. But being root you can change permissions and only then access files\objects. The typical case for this is the Windows system files on modern Windows versions (Vista and higher): most of them belong to the TrustedInstaller user, and no one other ...


0

I think the problem is your mount filesystem type of hfs+ which I don’t even see in my local Mac OS X 10.9.5 (Mavericks) setup when I run ls -l1 /System/Library/Filesystems/: AppleShare NetFSPlugins acfs.fs afpfs.fs cd9660.fs cddafs.fs exfat.fs ftp.fs hfs.fs msdos.fs nfs.fs ntfs.fs smbfs.fs udf.fs webdav.fs So my advice would be to just run the command ...


2

Use run-shell -b: With -b, the command is run in the background.


0

Remove the backticks. This seems to work for me. Is this what you wanted? #!/bin/sh a=$1 b=$2 echo "a=$a" echo "b=$b" $a | $b


0

It helps if you keep in mind the history behind this. The first shells were written when demands were more simple & people hadn't thought of more complex use cases, or common pitfalls, or commonly needed yet absent features. As people used shells more and more often, improvements came about often under the same shell name. Once in a while incremental ...


0

This one liner might look ugly but I think it does the job (if I understand your use case correctly). your_shell_script.sh | cut -d ' ' -f 1 | tr '\n' ',' | sed 's/,$/\n/'; your_shell_script.sh | cut -d ' ' -f '2-' | tr '\n' ',' | sed 's/,$/\n/'


0

It is a loop script, so it will overwrite the variable every loop. My suggestion here, is to create logfile for the "report" and a logfile for "date" too (append log). At the end of your script (right below the "done" line), execute the command below: cat <\report_log_file> | xargs echo | tr ' ' ','; cat <\date_log_file> | xargs echo | | tr ' ...


5

When you think about how long computers have been around there really aren't that many widely available shells if you ask me. Those that we commonly know are those that some people (for whatever reason) prefer and those that we have the rights to use on our system. Practically, any language which is interpreted can be used as a shell. In fact, your browser ...


0

AS it is my work i tried to get the output Thank you @DavidPostill you made me to try by self for var in cat EMP.txt | tail –n +2 #tail -n +2 if for removing the header do sal=echo $var | cut -d "," -f6#for seleceting salary field if [ $sal -gt 20000 ] then echo $var ...


1

Another solution is this one: http://stackoverflow.com/questions/11231937/bash-ignoring-error-for-a-particular-command Just add an OR-statement after your command: rm -rf my/dir || true This way, when statement #1 fails (throws error), run statement #2, which is simply true.


2

this answer might cover it Spaces in Linux environmental variables? You put the environment variable in double quotes. example demonstrating that below I am doing ls 'asdf asdf' which is ls on one file 'adsf asdf' with a space in the filename. I want to do it with a variable. You see with double quotes it gets the result. With no quotes it treats the space ...


-1

Prepend any Space character with Escape string, so the Space will be in the string as '\ ' (backslash + space). Hope this help.


0

I have built a set of shell functions that does exactly what I needed. https://github.com/google/cwd_jmp From the README jmp.sh is a bash 4.x library that enables relative bookmarking of file system directories including tab completion.


0

I don't think you will be able to achieve this with a keyboard shortcut easily. However, since your running the script in the background could you not just run something like kill $( ps aux | grep '[s]cript_name' | awk '{ print $2 }' ); In the current session? Could make it easier by placing that in a shell script called kill_script_name


-1

Since you know the name of the process, you can use killall: $ killall "Google Chrome"



Top 50 recent answers are included