Tag Info

Hot answers tagged

8

The weird string "@(#)" is actually used by the ancient SCCS version control system. Specifically, the what command would look through a file (binary or text) and find ASCII-Nul-terminated strings that started with "@(#)", and print that string out. That allowed you to embed printable ASCII version numbers in ".o" files and ultimately executables, so you ...


4

stty and older versions of who am i will issue error messages when they're not connected to a tty device. stty checks stdin (fd 0); I don't know what file descriptor who checks. To avoid getting those error messages, the usual workaround has been to use the -t option of test (more commonly known as [) to check if the shell is connected to a tty. if [ -t 0 ] ...


3

Not sure what you mean. Possibly with GNU grep: grep -Ero '(\\x[[:xdigit:]]{2})+' . To match strings of the format \xNN (the 4 characters backslash, x and two hexadecimal digits)


3

You can use the literal newline in PS1: PS1="$_timedhms > [USERNAME]MACHINE:${PWD#$HOME/} $ " or using $'\n' with ksh93: PS1="$_timedhms$'\n' [USERNAME]MACHINE:${PWD#$HOME/} $ "


3

Your script, at the first time is using who not whoami. Change it and you should get the result you expect.


2

printf "Are you sure you want to copy %s (y/n) ? (file bigger than 10 MB: %lu) " "$0" \ "$(wc -c < "$0")" parsing the output of ls is not reliable (and you've forgotten the $(...) around it).


1

You can do the following #!/bin/bash read -p "URL to check: " url if curl --output /dev/null --silent --head --fail "$url"; then printf '%s\n' "$url exist" else printf '%s\n' "$url does not exist" fi The if statements are not necessary though, I put them here just to illustrate the flow of the script.


1

curl -Is http://www.yourURL.com | head -1 You can try this command to check any URL.Status code 200 OK means that the request has succeeded and the URL is reachable. You can also test URL availability and get the response code using telnet command telnet www.yourURL.com 80 80 is the port number.


1

Thanks to @St├ęphaneChazelas - I was able to get my PS1 prompt exactly the way I want it. I remove the customizations from my .profile file, and appended the following to my .envfile. I was not aware of this, but the .envfile is processed after the .profile file. #set the prompt to include the date and time set -o allexport unset _Y _M _D _h _m _s eval ...


1

It would probably be easier to have two separate versions of the script. Since it is short it may not be worth adding extra code to handle the differences between the two formats as jw013 suggested. On the other hand if you had a larger script it would probably be easier to have one and make the script execute different commands depending on where it is ...


1

AIX sed does not understand escape sequence characters, as the AIX sed document said, it only know ASCII characters. So you should use another tools. tail tail -c +4 old.java > tmp.java awk awk '{NR==1{sub(/^\xef\xbb\xbf/,"")}1' old.java > tmp.java



Only top voted, non community-wiki answers of a minimum length are eligible