I have two files, file1 and file2, where the target_id compose the first column in both. I want to compare file1 to file2, and only keep the rows of file1 which match the target_id in file2. file2: Any help would be appreciated. % grep -x -f file1 file2 resulted in no output in my terminal Answer Sample data that actually
Tag: command-line
How to sort files by word count in linux?
I have to sort files in current directory based on word count by using command wc and pipe | necessarily. What command do I have to use? I thought I had to use a command sort | wc -w, but I failed. Answer I think this can help. The ls -1 will list all files of the current directory, and
How to copy files containing the given character using terminal in Linux Mint?
In Linux Mint, I have a directory that has many files and I want to copy files that contain x in their filename and paste them into other destination. How can I do it using a terminal? Answer Go to the directory that contains all of your files, then try this one. this commnad can help you. replace YourDestination wtih
What does ‘< <' command do in bash?
I can see >> is append and > is overwrite but I do not know what < < does with a space in the middle. What does this do, and does the direction of these arrows matter? For example: Answer < redirects a file as input to a command. <(…) is a process substitution – it is replaced by a
jq script file not getting the key/value pair
I would like to put all jq filters inside a text file and use the jq -L option to execute the filters. However, I can’t get this simple thing working. Inside my sample2.json file, I have: Inside my json2csv file, I have: When I do: The output is the whole sample.json file, like this: but I would expect the output
How to update local files to Google Drive using command line Linux
I am new to Linux and I want to upload/update my local files to Google Drive automatically using the Linux command. Does someone have experience before? Appreciate it if someone can provide me with my resources/step by step to do it. Thanks. Answer I don’t have experience with it but I found this article online that seems to do what
Replacing line of text cointing using sed
I’m trying to replace document.querySelector(‘.popup’).classList.add(‘active’) by document.querySelector(‘.popup’).classList.add(‘noactive’) Answer You can use See the online demo. The regex is POSIX BRE compliant and matches (document.querySelector(‘.popup’).classList.add(‘) – Group 1 (1): a literal document.querySelector(‘.popup’).classList.add(‘ text (active’)) – Group 2 (2): a literal active’) text. Note the capturing groups in a POSIX BRE regex are set with (…). The literal dots need escaping and
Why not able to push the new added files on remote repository?
I am new to Git. I have recently created a repository and uploaded a folder in it using the following sequence of commands: This was my first time when I uploaded the files to this repository. Now I am trying to upload more files to this repository using the following commands: But, I am getting the following information: Why is
In Linux Shell, how to find out which commands I use most often and how often?
I want to find out which are the top 5 commands that I ran in the shell. I want to see which commands I use most often. It would be great if I can also see how often I ran these top commands. Is there an easy way to find it without installing any plugins? Answer You can do it
Add more new lines to end of line in stdout
I want to be able to print out my logs with extra new lines. This is what the logs look like They look much cluttered in the terminal and although there is a newline, I want to add 1 more newline to make it more readable. I tried using and to no avail. Answer Not entirely certain about portability, but